diff --git a/attributes/maestro-schema.h b/attributes/maestro-schema.h index eb0264b82582ec9ac0b784de42fd82f838f39716..51ce6f3a1c45a059cb7a9d2e95b4dba56d59202d 100644 --- a/attributes/maestro-schema.h +++ b/attributes/maestro-schema.h @@ -151,5 +151,27 @@ mstro_attributes_default(mstro_schema schema, mstro_attribute_dict *result); +/** Look up maestro attribute in dictionary. + * + * On successful lookup return MSTRO_OK, *valtype set appropriately, + * and *val_p set to a (read-only) reference of the value that can be + * cast to the type documented for the respective kind of @ref + * mstro_cdo_attr_value_type. + * + * The reference stays alive at least until the dictionary is + * deallocated, or until the value is replaced by a call to @ref + * mstro_attribute_dict_set(). + * + * If key is unknown return MSTRO_NOENT and *valtype==MSTRO_CDO_ATTTR_VALUE_NA. + * + * If key is known but has no value, return MSTRO_NOENT, and *valtype==MSTRO_CDO_ATTTR_VALUE_INVALID + * + * otherwise returns other error code + */ +mstro_status +mstro_attribute_dict_get(mstro_attribute_dict dict, + const char *key, + enum mstro_cdo_attr_value_type *valtype, + const void **val_p); #endif diff --git a/include/maestro/attributes.h b/include/maestro/attributes.h index ac9e34e75936991854ad6040d84d08d5d4fdfe92..46ebbfd73ca9e862be948c2e1e722b6c8e05b7b3 100644 --- a/include/maestro/attributes.h +++ b/include/maestro/attributes.h @@ -202,7 +202,7 @@ mstro_timestamp_to_tm_local(const mstro_timestamp *tsp, struct tm *tmp); /** Built-in Maestro attribute data types */ -enum mstro_cdo_attr_value_types { +enum mstro_cdo_attr_value_type { /** Invalid value */ MSTRO_CDO_ATTR_VALUE_INVALID = 0, @@ -275,7 +275,7 @@ mstro_cdo_attribute_set(mstro_cdo cdo, const char* key, void* val); **/ mstro_status mstro_cdo_attribute_get(mstro_cdo cdo, const char*key, - enum mstro_cdo_attr_value_types *valtype, + enum mstro_cdo_attr_value_type *valtype, const void * * val_p); /** diff --git a/include/maestro/i_attributes.h b/include/maestro/i_attributes.h index 23286d5110e158b50e7c00e41309af01209005c3..36d5af9b96fa175429700f9ba829be0a059a01e0 100644 --- a/include/maestro/i_attributes.h +++ b/include/maestro/i_attributes.h @@ -135,7 +135,7 @@ mstro_cdo_attr_table__destroy(mstro_cdo_attr_table tab); mstro_status mstro_cdo_attr_table__lookup(const mstro_cdo cdo, const char *key, - enum mstro_cdo_attr_value_types *valtype, + enum mstro_cdo_attr_value_type *valtype, void **value_dst); /**@brief Insert an attribute, based on YAML string (key,value) pair diff --git a/maestro/attributes.c b/maestro/attributes.c index 08e7823062b094717707cb5716d6cd5e82846858..caf509ea379a75f677dd60785e302aea17cf21e3 100644 --- a/maestro/attributes.c +++ b/maestro/attributes.c @@ -171,7 +171,7 @@ SUCCESS: mstro_status mstro_cdo_attribute_get(mstro_cdo cdo, const char* key, - enum mstro_cdo_attr_value_types *type, + enum mstro_cdo_attr_value_type *type, const void ** val_p) { if (key == NULL || cdo == NULL) diff --git a/maestro/cdo.c b/maestro/cdo.c index ae3490938df91381c0b64d13c26896a55b060994..3ee65835953a8d1cc94cd61eacb173c2a756efd4 100644 --- a/maestro/cdo.c +++ b/maestro/cdo.c @@ -398,7 +398,7 @@ mstro_cdo_declaration_seal(mstro_cdo cdo) } else if(cdo->raw_ptr!=NULL) { uint64_t raw_ptr_size; /* size_t is not portable enough, so the schema says '64 bit' */ void * val; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; status = mstro_cdo_attr_table__lookup( cdo, /* FIXME: should use the well-defined one FQAN */ @@ -599,7 +599,7 @@ mstro_cdo_offer(mstro_cdo cdo) { void* val; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; status = mstro_cdo_attr_table__lookup( cdo, /* FIXME: should use the well-defined one FQAN */ diff --git a/maestro/cdo_attributes_schema.c b/maestro/cdo_attributes_schema.c index 151ebbcc80886beb4c72e992e7adae493b625c16..bb83d96b86758c3084023fead12a79926c48c370 100644 --- a/maestro/cdo_attributes_schema.c +++ b/maestro/cdo_attributes_schema.c @@ -135,7 +135,7 @@ mstro_cdo_attributes_parse_string(mstro_cdo cdo) return MSTRO_OK; } -enum mstro_cdo_attr_value_types +enum mstro_cdo_attr_value_type mstro_cdo_attr__match_type_cyaml(enum cyaml_type t, uint32_t size) { switch (t) { @@ -197,7 +197,7 @@ mstro_cdo_attr__match_key_schema(const cyaml_schema_field_t s[], size_t len, con mstro_status mstro_cdo_attr_table__lookup(mstro_cdo cdo, const char *key, - enum mstro_cdo_attr_value_types *valtype, + enum mstro_cdo_attr_value_type *valtype, void **value_dst) { // XXX how to navigate through the attribute table levels using the schema table? diff --git a/maestro/cdoid.c b/maestro/cdoid.c index db57eef2f896f1861549d341d01344482b1dc7ea..f8986967a2d6131bb3bc0578f077d67d1c8ed93d 100644 --- a/maestro/cdoid.c +++ b/maestro/cdoid.c @@ -54,7 +54,7 @@ static inline uint32_t udj__ntohl(uint32_t const net) { - uint8_t data[4] = {}; + uint8_t data[4] = {0,0,0,0}; memcpy(&data, &net, sizeof(data)); return ((uint32_t) data[3] <<0) | ((uint32_t) data[2] <<8) diff --git a/maestro/ofi.c b/maestro/ofi.c index fbf289293861c4f3251d1437ce2bb759537067e7..6851c21e7e0d2639ee4f2d526cb6b432386902a6 100644 --- a/maestro/ofi.c +++ b/maestro/ofi.c @@ -2092,7 +2092,7 @@ mstro_pc__handle_initiate_transfer(const Mstro__Pool__InitiateTransfer* init) ticket.cdoid = &id; const void *size; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; if (! (MSTRO_OK == mstro_cdo_attribute_get(src_cdo, "local_size", &type, &size))) { ERR("Couldn't retrieve CDO %s local_size needed for transport\n", src_cdo->name); return MSTRO_FAIL; diff --git a/tests/check_declaration_seal.c b/tests/check_declaration_seal.c index e670c18aee9b4b7ee095d68704a4924088cccf6d..117e5f1979d84eaabb184e5bbabf7c77c835186a 100644 --- a/tests/check_declaration_seal.c +++ b/tests/check_declaration_seal.c @@ -46,7 +46,7 @@ CHEAT_TEST(cdo_declaration_seal_works, cheat_assert(MSTRO_OK == mstro_init("Tests","DECLARE",0)); char name[] = "my_cdo_1"; mstro_cdo cdo=NULL; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; const void* val; uint64_t size; size = 16000; diff --git a/tests/check_pool_mamba.c b/tests/check_pool_mamba.c index b70261735d0e9f41ce5ff07ac588172940a93501..ed21aff915c332d361da8f7a441c1c91fd8fb97b 100644 --- a/tests/check_pool_mamba.c +++ b/tests/check_pool_mamba.c @@ -48,7 +48,7 @@ CHEAT_TEST(cdo_local_pool_mamba_works, mstro_cdo cdo=NULL; cheat_assert(MSTRO_OK == mstro_cdo_declare(name, MSTRO_ATTR_DEFAULT, &cdo)); uint64_t size = 4096; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; float* buf; void *rec; buf = malloc(sizeof(float)*size); diff --git a/tests/check_transport_gfs.c b/tests/check_transport_gfs.c index 0369281ab4f8976422cebd8e2e01470843c739e7..87bc1ff2cf0608dfc27337f61d763d9838c62610 100644 --- a/tests/check_transport_gfs.c +++ b/tests/check_transport_gfs.c @@ -84,7 +84,7 @@ CHEAT_DECLARE ( cheat_assert(MSTRO_OK == mstro_cdo_attribute_set(cdo_src, MSTRO_ATTR_CORE_CDO_SCOPE_LOCAL_SIZE, &bytes)); - enum mstro_cdo_attr_value_types ttype; + enum mstro_cdo_attr_value_type ttype; const void* tval; cheat_assert(MSTRO_OK == mstro_cdo_attribute_get(cdo_src, @@ -130,7 +130,7 @@ CHEAT_DECLARE ( double* data; size_t len; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; const void* val; cheat_assert(MSTRO_OK == mstro_cdo_access_ptr(cdo_dst, (void**)&data, NULL)); diff --git a/tests/demo_mvp_d3_2.c b/tests/demo_mvp_d3_2.c index 31605efe4f9725d4ff4427933df535e24233e363..f004909177517c5ac70d47677afa15c713453fd4 100644 --- a/tests/demo_mvp_d3_2.c +++ b/tests/demo_mvp_d3_2.c @@ -574,7 +574,7 @@ archiver_thread_fun(void *closure) /* extract mamba pointer */ mmbArray *mamba_array; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; s = mstro_cdo_access_mamba_array(incoming[i], &mamba_array); if(s!=MSTRO_OK) { @@ -832,7 +832,7 @@ consumer_thread_fun(void *closure) /* extract raw ptr */ void* rawptr; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; const void* size; s = mstro_cdo_access_ptr(incoming[i], &rawptr, NULL); if(s!=MSTRO_OK) { diff --git a/transport/gfs.c b/transport/gfs.c index 1fed4c6de64d9f1914f52122eb6e718a8cfab243..5359b292e595b45473212a8e3bf9fd1ffd0e7916 100644 --- a/transport/gfs.c +++ b/transport/gfs.c @@ -84,7 +84,7 @@ mstro_transport_gfs_dst_execute(mstro_cdo dst, } } else { const void *available_size; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; status = mstro_cdo_attribute_get( dst, MSTRO_ATTR_CORE_CDO_SCOPE_LOCAL_SIZE, &type, &available_size); if(status!=MSTRO_OK) { diff --git a/transport/transport.c b/transport/transport.c index 62311aa80410b682c84afe6279aca7ff6dfbd5c8..4334d4652c576f5b79da51b8f8257567db78380b 100644 --- a/transport/transport.c +++ b/transport/transport.c @@ -74,7 +74,7 @@ mstro_transport_get_dst_buffer(mstro_cdo dst, size_t len, void** data) } } else { const void *available_size; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; status = mstro_cdo_attribute_get( dst, MSTRO_ATTR_CORE_CDO_SCOPE_LOCAL_SIZE, &type, &available_size); if(status!=MSTRO_OK) { @@ -98,7 +98,7 @@ mstro_transport_get_dst_buffer(mstro_cdo dst, size_t len, void** data) mstro_status mstro_transport_get_datalen(mstro_cdo src, struct mstro_transport_datalen* dl) { - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; const void* val; if (src->raw_ptr != NULL ) { @@ -195,7 +195,7 @@ mstro_transport_ticket_issue( mstro_status status; - enum mstro_cdo_attr_value_types type; + enum mstro_cdo_attr_value_type type; const void* val; if (! (MSTRO_OK == mstro_cdo_attribute_get(src_cdo, "local_size", &type, &val))) { ERR("Couldn't retrieve CDO %s local_size needed for transport\n", src_cdo->name);