diff --git a/attributes/maestro-schema.c b/attributes/maestro-schema.c index 1dcda1d7c5fd3da687d33a1b757a34bdc5fa05fd..b9d6138da16858ce8a2aa4cce66973be7d95c5e6 100644 --- a/attributes/maestro-schema.c +++ b/attributes/maestro-schema.c @@ -1789,6 +1789,18 @@ mstro_attribute_dict__insert_default(mstro_attribute_dict dict, struct mstro_attribute_entry_ *entry=NULL; bool must_insert=false; mstro_status status = MSTRO_OK; + + mstro_schema_attribute attr=NULL; + status = mstro_schema_lookup_attribute(dict->schema, mstro_symbol_name(key), &attr); + if(status!=MSTRO_OK) { + ERR("Cannot find attribute in schema !? (should not happen here)\n"); + goto BAILOUT; + } + mstro_schema_type tdecl; + status = mstro_schema_lookup_type(dict->schema, attr->typespec, &tdecl); + if(status!=MSTRO_OK) { + goto BAILOUT; + } HASH_FIND(hh, dict->dict, &key, sizeof(mstro_symbol), entry); if(!entry) { @@ -1797,25 +1809,17 @@ mstro_attribute_dict__insert_default(mstro_attribute_dict dict, ERR("Cannot allocate default entry\n"); goto BAILOUT; } - must_insert=true; + entry->kind=tdecl->parsed_type->kind; + status = mstro_attribute_entry__set_size(entry, entry->kind); if(status!=MSTRO_OK) { + ERR("Cannot set entry size\n"); goto BAILOUT; } entry->val = NULL; + must_insert=true; } - mstro_schema_attribute attr=NULL; - status = mstro_schema_lookup_attribute(dict->schema, mstro_symbol_name(key), &attr); - if(status!=MSTRO_OK) { - ERR("Cannot find attribute in schema !? (should not happen here)\n"); - goto BAILOUT; - } - mstro_schema_type tdecl; - status = mstro_schema_lookup_type(dict->schema, attr->typespec, &tdecl); - if(status!=MSTRO_OK) { - goto BAILOUT; - } assert(entry->kind = tdecl->parsed_type->kind); /* duplicate; if user-supplied: allocate freshly */ diff --git a/tests/check_declaration_seal.c b/tests/check_declaration_seal.c index 117e5f1979d84eaabb184e5bbabf7c77c835186a..a894559becb61b19434727d1deddc224b8810c5f 100644 --- a/tests/check_declaration_seal.c +++ b/tests/check_declaration_seal.c @@ -56,7 +56,7 @@ CHEAT_TEST(cdo_declaration_seal_works, cheat_assert(MSTRO_OK == mstro_cdo_attribute_get( - cdo, "allocate_now", &type, &val)); + cdo, "allocate-now", &type, &val)); fprintf(stdout, "check: default allocate_now: %d (%p)\n", *(const int*)val, val);