X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fctf-ir%2Ffield-types.c;h=485c5e8f3ea71e2f68d6b84f62559af01c5a57e2;hb=1974687e6b7a08d8383a4a5c75265d0ed3b8c5c9;hp=0cd55f4d4a27a7e9d0da465b3ced4ac12cf27285;hpb=ec159b1e42a1b16c174c729dd36da1c1e4202f69;p=babeltrace.git diff --git a/lib/ctf-ir/field-types.c b/lib/ctf-ir/field-types.c index 0cd55f4d..485c5e8f 100644 --- a/lib/ctf-ir/field-types.c +++ b/lib/ctf-ir/field-types.c @@ -981,7 +981,7 @@ end: } int bt_ctf_field_type_integer_set_size(struct bt_ctf_field_type *type, - size_t size) + unsigned int size) { int ret = 0; struct bt_ctf_field_type_integer *integer; @@ -1073,6 +1073,7 @@ int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *type, } switch (base) { + case BT_CTF_INTEGER_BASE_UNSPECIFIED: case BT_CTF_INTEGER_BASE_BINARY: case BT_CTF_INTEGER_BASE_OCTAL: case BT_CTF_INTEGER_BASE_DECIMAL: @@ -1181,7 +1182,8 @@ end: return clock_class; } -int bt_ctf_field_type_integer_set_mapped_clock_class( +BT_HIDDEN +int bt_ctf_field_type_integer_set_mapped_clock_class_no_check( struct bt_ctf_field_type *type, struct bt_ctf_clock_class *clock_class) { @@ -1200,10 +1202,10 @@ int bt_ctf_field_type_integer_set_mapped_clock_class( goto end; } - if (type->frozen) { - BT_LOGW("Invalid parameter: field type is frozen: addr=%p", - type); - ret = -1; + if (type->id != BT_CTF_FIELD_TYPE_ID_INTEGER) { + BT_LOGW("Invalid parameter: field type is not an integer field type: " + "addr=%p, ft-id=%s", type, + bt_ctf_field_type_id_string(type->id)); goto end; } @@ -1226,6 +1228,32 @@ end: return ret; } +int bt_ctf_field_type_integer_set_mapped_clock_class( + struct bt_ctf_field_type *type, + struct bt_ctf_clock_class *clock_class) +{ + int ret = 0; + + if (!type) { + BT_LOGW_STR("Invalid parameter: field type is NULL."); + ret = -1; + goto end; + } + + if (type->frozen) { + BT_LOGW("Invalid parameter: field type is frozen: addr=%p", + type); + ret = -1; + goto end; + } + + ret = bt_ctf_field_type_integer_set_mapped_clock_class_no_check( + type, clock_class); + +end: + return ret; +} + static void bt_ctf_field_type_enum_iter_destroy(struct bt_object *obj) { @@ -1295,13 +1323,18 @@ bt_ctf_field_type_enumeration_find_mappings_by_name( iter->u.name_quark = g_quark_try_string(name); if (!iter->u.name_quark) { - BT_LOGE("Cannot get GQuark: string=\"%s\"", name); + BT_LOGV("No such enumeration field type mapping name: " + "ft-addr=%p, mapping-name=\"%s\"", + type, name); goto error; } /* Advance iterator to first entry, or leave index at -1. */ if (bt_ctf_field_type_enumeration_mapping_iterator_next(iter)) { /* No entry found. */ + BT_LOGV("No such enumeration field type mapping name: " + "ft-addr=%p, mapping-name=\"%s\"", + type, name); goto error; } @@ -2198,14 +2231,19 @@ struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name( name_quark = g_quark_try_string(name); if (!name_quark) { - BT_LOGE("Cannot get GQuark: string=\"%s\"", name); + BT_LOGV("No such structure field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, name); goto end; } structure = container_of(type, struct bt_ctf_field_type_structure, parent); if (!g_hash_table_lookup_extended(structure->field_name_to_index, - GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) { + GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) { + BT_LOGV("No such structure field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, name); goto end; } @@ -2482,13 +2520,18 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name( name_quark = g_quark_try_string(field_name); if (!name_quark) { - BT_LOGE("Cannot get GQuark: string=\"%s\"", field_name); + BT_LOGV("No such variant field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, field_name); goto end; } variant = container_of(type, struct bt_ctf_field_type_variant, parent); if (!g_hash_table_lookup_extended(variant->field_name_to_index, - GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) { + GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) { + BT_LOGV("No such variant field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, field_name); goto end; } @@ -3181,7 +3224,7 @@ int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type, byte_order != BT_CTF_BYTE_ORDER_LITTLE_ENDIAN && byte_order != BT_CTF_BYTE_ORDER_BIG_ENDIAN && byte_order != BT_CTF_BYTE_ORDER_NETWORK) { - BT_LOGW("Invalid parameter: unknown byte order: " + BT_LOGW("Invalid parameter: invalid byte order: " "addr=%p, bo=%s", type, bt_ctf_byte_order_string(byte_order)); ret = -1; @@ -3414,7 +3457,9 @@ int bt_ctf_field_type_structure_get_field_name_index( name_quark = g_quark_try_string(name); if (!name_quark) { - BT_LOGE("Cannot get GQuark: string=\"%s\"", name); + BT_LOGV("No such structure field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, name); ret = -1; goto end; } @@ -3424,6 +3469,9 @@ int bt_ctf_field_type_structure_get_field_name_index( if (!g_hash_table_lookup_extended(structure->field_name_to_index, GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) { + BT_LOGV("No such structure field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, name); ret = -1; goto end; } @@ -3463,7 +3511,9 @@ int bt_ctf_field_type_variant_get_field_name_index( name_quark = g_quark_try_string(name); if (!name_quark) { - BT_LOGE("Cannot get GQuark: string=\"%s\"", name); + BT_LOGV("No such variant field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, name); ret = -1; goto end; } @@ -3473,6 +3523,9 @@ int bt_ctf_field_type_variant_get_field_name_index( if (!g_hash_table_lookup_extended(variant->field_name_to_index, GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) { + BT_LOGV("No such variant field type field name: " + "ft-addr=%p, field-name=\"%s\"", + type, name); ret = -1; goto end; } @@ -3848,6 +3901,7 @@ const char *get_integer_base_string(enum bt_ctf_integer_base base) switch (base) { case BT_CTF_INTEGER_BASE_DECIMAL: + case BT_CTF_INTEGER_BASE_UNSPECIFIED: base_string = "decimal"; break; case BT_CTF_INTEGER_BASE_HEXADECIMAL: @@ -3997,7 +4051,7 @@ int bt_ctf_field_type_structure_serialize(struct bt_ctf_field_type *type, { size_t i; unsigned int indent; - int64_t ret = 0; + int ret = 0; struct bt_ctf_field_type_structure *structure = container_of(type, struct bt_ctf_field_type_structure, parent); GString *structure_field_name = context->field_name; @@ -4013,7 +4067,7 @@ int bt_ctf_field_type_structure_serialize(struct bt_ctf_field_type *type, struct structure_field *field = structure->fields->pdata[i]; BT_LOGD("Serializing structure field type's field metadata: " - "index=%" PRId64 ", " + "index=%zu, " "field-ft-addr=%p, field-name=\"%s\"", i, field, g_quark_to_string(field->name)); @@ -4027,7 +4081,7 @@ int bt_ctf_field_type_structure_serialize(struct bt_ctf_field_type *type, ret = bt_ctf_field_type_serialize(field->type, context); if (ret) { BT_LOGW("Cannot serialize structure field type's field's metadata: " - "index=%" PRId64 ", " + "index=%zu, " "field-ft-addr=%p, field-name=\"%s\"", i, field->type, g_quark_to_string(field->name)); @@ -4081,7 +4135,7 @@ int bt_ctf_field_type_variant_serialize(struct bt_ctf_field_type *type, struct structure_field *field = variant->fields->pdata[i]; BT_LOGD("Serializing variant field type's field metadata: " - "index=%" PRId64 ", " + "index=%zu, " "field-ft-addr=%p, field-name=\"%s\"", i, field, g_quark_to_string(field->name)); @@ -4097,7 +4151,7 @@ int bt_ctf_field_type_variant_serialize(struct bt_ctf_field_type *type, ret = bt_ctf_field_type_serialize(field->type, context); if (ret) { BT_LOGW("Cannot serialize variant field type's field's metadata: " - "index=%" PRId64 ", " + "index=%zu, " "field-ft-addr=%p, field-name=\"%s\"", i, field->type, g_quark_to_string(field->name)); @@ -4662,7 +4716,6 @@ struct bt_ctf_field_type *bt_ctf_field_type_string_copy( struct bt_ctf_field_type *type) { struct bt_ctf_field_type *copy; - struct bt_ctf_field_type_string *string; BT_LOGD("Copying string field type's: addr=%p", type); copy = bt_ctf_field_type_string_create(); @@ -4671,8 +4724,6 @@ struct bt_ctf_field_type *bt_ctf_field_type_string_copy( goto end; } - string = container_of(type, struct bt_ctf_field_type_string, - parent); BT_LOGD("Copied string field type: original-ft-addr=%p, copy-ft-addr=%p", type, copy); end: @@ -4740,8 +4791,8 @@ int bt_ctf_field_type_integer_compare(struct bt_ctf_field_type *type_a, if (int_type_a->mapped_clock != int_type_b->mapped_clock) { BT_LOGV("Integer field types differ: different mapped clock classes: " "ft-a-mapped-clock-class-addr=%p, " - "ft-b-mapped-clock-class-addr=%p, ", - "ft-a-mapped-clock-class-name=\"%s\", ", + "ft-b-mapped-clock-class-addr=%p, " + "ft-a-mapped-clock-class-name=\"%s\", " "ft-b-mapped-clock-class-name=\"%s\"", int_type_a->mapped_clock, int_type_b->mapped_clock, int_type_a->mapped_clock ? bt_ctf_clock_class_get_name(int_type_a->mapped_clock) : "", @@ -4781,7 +4832,7 @@ int bt_ctf_field_type_floating_point_compare(struct bt_ctf_field_type *type_a, /* Exponent length */ if (float_a->exp_dig != float_b->exp_dig) { BT_LOGV("Floating point number field types differ: different exponent sizes: " - "ft-a-exp-size=%s, ft-b-exp-size=%s", + "ft-a-exp-size=%u, ft-b-exp-size=%u", float_a->exp_dig, float_b->exp_dig); goto end; } @@ -4789,7 +4840,7 @@ int bt_ctf_field_type_floating_point_compare(struct bt_ctf_field_type *type_a, /* Mantissa length */ if (float_a->mant_dig != float_b->mant_dig) { BT_LOGV("Floating point number field types differ: different mantissa sizes: " - "ft-a-mant-size=%s, ft-b-mant-size=%s", + "ft-a-mant-size=%u, ft-b-mant-size=%u", float_a->mant_dig, float_b->mant_dig); goto end; } @@ -4947,7 +4998,7 @@ int compare_structure_fields(struct structure_field *field_a, ret = bt_ctf_field_type_compare(field_a->type, field_b->type); if (ret == 1) { BT_LOGV("Structure/variant field type fields differ: different field types: " - "field-name=\"%s\", field-a-ft-addr=%s, field-b-ft-addr=%s", + "field-name=\"%s\", field-a-ft-addr=%p, field-b-ft-addr=%p", g_quark_to_string(field_a->name), field_a->type, field_b->type); } @@ -5026,7 +5077,7 @@ int bt_ctf_field_type_variant_compare(struct bt_ctf_field_type *type_a, /* Tag name */ if (strcmp(variant_a->tag_name->str, variant_b->tag_name->str)) { BT_LOGV("Variant field types differ: different tag field names: " - "ft-a-tag-field-name=%u, ft-b-tag-field-name=%u", + "ft-a-tag-field-name=\"%s\", ft-b-tag-field-name=\"%s\"", variant_a->tag_name->str, variant_b->tag_name->str); goto end; } @@ -5124,7 +5175,8 @@ int bt_ctf_field_type_sequence_compare(struct bt_ctf_field_type *type_a, if (strcmp(sequence_a->length_field_name->str, sequence_b->length_field_name->str)) { BT_LOGV("Sequence field types differ: different length field names: " - "ft-a-length-field-name=%u, ft-b-length-field-name=%u", + "ft-a-length-field-name=\"%s\", " + "ft-b-length-field-name=\"%s\"", sequence_a->length_field_name->str, sequence_b->length_field_name->str); goto end;