From 5934a96fbc7470b8973b62238d68e6cfc3c31493 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Thu, 24 Feb 2022 15:06:03 -0500 Subject: [PATCH] sink.ctf.fs: remove unused `fs_sink_ctf_field_class::index_in_parent` field This field is not used anywhere and looks like a leftover from a previous iteration of the sink. Let's remove it. Signed-off-by: Francis Deslauriers Change-Id: I64592c1561bd66e083e965903d8a9dc050a5756d Reviewed-on: https://review.lttng.org/c/babeltrace/+/7387 Reviewed-by: Philippe Proulx Reviewed-on: https://review.lttng.org/c/babeltrace/+/12189 Tested-by: jenkins CI-Build: Simon Marchi --- src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp | 69 ++++++++----------- .../fs-sink/translate-trace-ir-to-ctf-ir.cpp | 60 ++++++++-------- 2 files changed, 57 insertions(+), 72 deletions(-) diff --git a/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp b/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp index 6cde44fe..7161fb35 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp +++ b/src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp @@ -39,9 +39,6 @@ struct fs_sink_ctf_field_class const bt_field_class *ir_fc; unsigned int alignment; - - /* Index of the field class within its own parent */ - uint64_t index_in_parent; }; struct fs_sink_ctf_field_class_bit_array @@ -288,33 +285,31 @@ static inline void fs_sink_ctf_field_class_destroy(struct fs_sink_ctf_field_clas static inline void _fs_sink_ctf_field_class_init(struct fs_sink_ctf_field_class *fc, enum fs_sink_ctf_field_class_type type, const bt_field_class *ir_fc, - unsigned int alignment, uint64_t index_in_parent) + unsigned int alignment) { BT_ASSERT(fc); fc->type = type; fc->ir_fc = ir_fc; fc->alignment = alignment; - fc->index_in_parent = index_in_parent; } -static inline void _fs_sink_ctf_field_class_bit_array_init( - struct fs_sink_ctf_field_class_bit_array *fc, enum fs_sink_ctf_field_class_type type, - const bt_field_class *ir_fc, unsigned int size, uint64_t index_in_parent) +static inline void +_fs_sink_ctf_field_class_bit_array_init(struct fs_sink_ctf_field_class_bit_array *fc, + enum fs_sink_ctf_field_class_type type, + const bt_field_class *ir_fc, unsigned int size) { - _fs_sink_ctf_field_class_init(&fc->base, type, ir_fc, size % 8 == 0 ? 8 : 1, index_in_parent); + _fs_sink_ctf_field_class_init(&fc->base, type, ir_fc, size % 8 == 0 ? 8 : 1); fc->size = size; } static inline void _fs_sink_ctf_field_class_int_init(struct fs_sink_ctf_field_class_int *fc, enum fs_sink_ctf_field_class_type type, - const bt_field_class *ir_fc, - uint64_t index_in_parent) + const bt_field_class *ir_fc) { bt_field_class_type ir_fc_type = bt_field_class_get_type(ir_fc); _fs_sink_ctf_field_class_bit_array_init( - &fc->base, type, ir_fc, (unsigned int) bt_field_class_integer_get_field_value_range(ir_fc), - index_in_parent); + &fc->base, type, ir_fc, (unsigned int) bt_field_class_integer_get_field_value_range(ir_fc)); fc->is_signed = bt_field_class_type_is(ir_fc_type, BT_FIELD_CLASS_TYPE_SIGNED_INTEGER); } @@ -341,7 +336,7 @@ _fs_sink_ctf_named_field_class_fini(struct fs_sink_ctf_named_field_class *named_ } static inline struct fs_sink_ctf_field_class_bit_array * -fs_sink_ctf_field_class_bit_array_create(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_bit_array_create(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_bit_array *fc = g_new0(struct fs_sink_ctf_field_class_bit_array, 1); @@ -349,12 +344,12 @@ fs_sink_ctf_field_class_bit_array_create(const bt_field_class *ir_fc, uint64_t i BT_ASSERT(fc); _fs_sink_ctf_field_class_bit_array_init( fc, FS_SINK_CTF_FIELD_CLASS_TYPE_BIT_ARRAY, ir_fc, - (unsigned int) bt_field_class_bit_array_get_length(ir_fc), index_in_parent); + (unsigned int) bt_field_class_bit_array_get_length(ir_fc)); return fc; } static inline struct fs_sink_ctf_field_class_bool * -fs_sink_ctf_field_class_bool_create(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_bool_create(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_bool *fc = g_new0(struct fs_sink_ctf_field_class_bool, 1); @@ -364,79 +359,73 @@ fs_sink_ctf_field_class_bool_create(const bt_field_class *ir_fc, uint64_t index_ * CTF 1.8 has no boolean field class type, so this component * translates it to an 8-bit unsigned integer field class. */ - _fs_sink_ctf_field_class_bit_array_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL, ir_fc, 8, - index_in_parent); + _fs_sink_ctf_field_class_bit_array_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL, ir_fc, 8); return fc; } static inline struct fs_sink_ctf_field_class_int * -fs_sink_ctf_field_class_int_create(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_int_create(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_int *fc = g_new0(struct fs_sink_ctf_field_class_int, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_int_init(fc, FS_SINK_CTF_FIELD_CLASS_TYPE_INT, ir_fc, index_in_parent); + _fs_sink_ctf_field_class_int_init(fc, FS_SINK_CTF_FIELD_CLASS_TYPE_INT, ir_fc); return fc; } static inline struct fs_sink_ctf_field_class_float * -fs_sink_ctf_field_class_float_create(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_float_create(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_float *fc = g_new0(struct fs_sink_ctf_field_class_float, 1); BT_ASSERT(fc); _fs_sink_ctf_field_class_bit_array_init( &fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT, ir_fc, - bt_field_class_get_type(ir_fc) == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL ? 32 : 64, - index_in_parent); + bt_field_class_get_type(ir_fc) == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL ? 32 : 64); return fc; } static inline struct fs_sink_ctf_field_class_string * -fs_sink_ctf_field_class_string_create(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_string_create(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_string *fc = g_new0(struct fs_sink_ctf_field_class_string, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_STRING, ir_fc, 8, - index_in_parent); + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_STRING, ir_fc, 8); return fc; } static inline struct fs_sink_ctf_field_class_struct * -fs_sink_ctf_field_class_struct_create_empty(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_struct_create_empty(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_struct *fc = g_new0(struct fs_sink_ctf_field_class_struct, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT, ir_fc, 1, - index_in_parent); + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT, ir_fc, 1); fc->members = g_array_new(FALSE, TRUE, sizeof(struct fs_sink_ctf_named_field_class)); BT_ASSERT(fc->members); return fc; } static inline struct fs_sink_ctf_field_class_option * -fs_sink_ctf_field_class_option_create_empty(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_option_create_empty(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_option *fc = g_new0(struct fs_sink_ctf_field_class_option, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION, ir_fc, 1, - index_in_parent); + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_OPTION, ir_fc, 1); fc->tag_ref = g_string_new(NULL); BT_ASSERT(fc->tag_ref); return fc; } static inline struct fs_sink_ctf_field_class_variant * -fs_sink_ctf_field_class_variant_create_empty(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_variant_create_empty(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_variant *fc = g_new0(struct fs_sink_ctf_field_class_variant, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT, ir_fc, 1, - index_in_parent); + _fs_sink_ctf_field_class_init(&fc->base, FS_SINK_CTF_FIELD_CLASS_TYPE_VARIANT, ir_fc, 1); fc->options = g_array_new(FALSE, TRUE, sizeof(struct fs_sink_ctf_named_field_class)); BT_ASSERT(fc->options); fc->tag_ref = g_string_new(NULL); @@ -447,26 +436,24 @@ fs_sink_ctf_field_class_variant_create_empty(const bt_field_class *ir_fc, uint64 } static inline struct fs_sink_ctf_field_class_array * -fs_sink_ctf_field_class_array_create_empty(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_array_create_empty(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_array *fc = g_new0(struct fs_sink_ctf_field_class_array, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init(&fc->base.base, FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY, ir_fc, 1, - index_in_parent); + _fs_sink_ctf_field_class_init(&fc->base.base, FS_SINK_CTF_FIELD_CLASS_TYPE_ARRAY, ir_fc, 1); fc->length = bt_field_class_array_static_get_length(ir_fc); return fc; } static inline struct fs_sink_ctf_field_class_sequence * -fs_sink_ctf_field_class_sequence_create_empty(const bt_field_class *ir_fc, uint64_t index_in_parent) +fs_sink_ctf_field_class_sequence_create_empty(const bt_field_class *ir_fc) { struct fs_sink_ctf_field_class_sequence *fc = g_new0(struct fs_sink_ctf_field_class_sequence, 1); BT_ASSERT(fc); - _fs_sink_ctf_field_class_init(&fc->base.base, FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE, ir_fc, 1, - index_in_parent); + _fs_sink_ctf_field_class_init(&fc->base.base, FS_SINK_CTF_FIELD_CLASS_TYPE_SEQUENCE, ir_fc, 1); fc->length_ref = g_string_new(NULL); BT_ASSERT(fc->length_ref); fc->length_is_before = diff --git a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp index 72a29140..6d52bf2a 100644 --- a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp +++ b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp @@ -26,7 +26,6 @@ struct field_path_elem { - uint64_t index_in_parent; GString *name; /* Weak */ @@ -152,8 +151,8 @@ end: return must_protect; } -static inline int cur_path_stack_push(struct ctx *ctx, uint64_t index_in_parent, const char *name, - bool force_protect_name, const bt_field_class *ir_fc, +static inline int cur_path_stack_push(struct ctx *ctx, const char *name, bool force_protect_name, + const bt_field_class *ir_fc, struct fs_sink_ctf_field_class *parent_fc) { int ret = 0; @@ -161,7 +160,6 @@ static inline int cur_path_stack_push(struct ctx *ctx, uint64_t index_in_parent, g_array_set_size(ctx->cur_path, ctx->cur_path->len + 1); field_path_elem = cur_path_stack_top(ctx); - field_path_elem->index_in_parent = index_in_parent; field_path_elem->name = g_string_new(NULL); if (name) { @@ -605,7 +603,7 @@ static inline int translate_structure_field_class_members( member = bt_field_class_structure_borrow_member_by_index_const(ir_fc, i); name = bt_field_class_structure_member_get_name(member); memb_ir_fc = bt_field_class_structure_member_borrow_field_class_const(member); - ret = cur_path_stack_push(ctx, i, name, true, memb_ir_fc, &struct_fc->base); + ret = cur_path_stack_push(ctx, name, true, memb_ir_fc, &struct_fc->base); if (ret) { BT_COMP_LOGE("Cannot translate structure field class member: " "name=\"%s\"", @@ -631,8 +629,8 @@ end: static inline int translate_structure_field_class(struct ctx *ctx) { int ret; - struct fs_sink_ctf_field_class_struct *fc = fs_sink_ctf_field_class_struct_create_empty( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_struct *fc = + fs_sink_ctf_field_class_struct_create_empty(cur_path_stack_top(ctx)->ir_fc); BT_ASSERT(fc); append_to_parent_field_class(ctx, &fc->base); @@ -844,8 +842,8 @@ end: static inline int translate_option_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_option *fc = fs_sink_ctf_field_class_option_create_empty( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_option *fc = + fs_sink_ctf_field_class_option_create_empty(cur_path_stack_top(ctx)->ir_fc); const bt_field_class *content_ir_fc = bt_field_class_option_borrow_field_class_const(fc->base.ir_fc); int ret; @@ -864,7 +862,7 @@ static inline int translate_option_field_class(struct ctx *ctx) * unsigned enumeration field class). */ append_to_parent_field_class(ctx, &fc->base); - ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, content_ir_fc, &fc->base); + ret = cur_path_stack_push(ctx, NULL, false, content_ir_fc, &fc->base); if (ret) { BT_COMP_LOGE_STR("Cannot translate option field class content."); goto end; @@ -887,8 +885,8 @@ static inline int translate_variant_field_class(struct ctx *ctx) { int ret = 0; uint64_t i; - struct fs_sink_ctf_field_class_variant *fc = fs_sink_ctf_field_class_variant_create_empty( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_variant *fc = + fs_sink_ctf_field_class_variant_create_empty(cur_path_stack_top(ctx)->ir_fc); bt_field_class_type ir_fc_type; const bt_field_path *ir_selector_field_path = NULL; struct fs_sink_ctf_field_class *tgt_fc = NULL; @@ -1015,7 +1013,7 @@ append_to_parent: * option name because it's already protected at this * point. */ - ret = cur_path_stack_push(ctx, i, prot_opt_name, false, opt_ir_fc, &fc->base); + ret = cur_path_stack_push(ctx, prot_opt_name, false, opt_ir_fc, &fc->base); if (ret) { BT_COMP_LOGE("Cannot translate variant field class option: " "name=\"%s\"", @@ -1045,15 +1043,15 @@ end: static inline int translate_static_array_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_array *fc = fs_sink_ctf_field_class_array_create_empty( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_array *fc = + fs_sink_ctf_field_class_array_create_empty(cur_path_stack_top(ctx)->ir_fc); const bt_field_class *elem_ir_fc = bt_field_class_array_borrow_element_field_class_const(fc->base.base.ir_fc); int ret; BT_ASSERT(fc); append_to_parent_field_class(ctx, &fc->base.base); - ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc, &fc->base.base); + ret = cur_path_stack_push(ctx, NULL, false, elem_ir_fc, &fc->base.base); if (ret) { BT_COMP_LOGE_STR("Cannot translate static array field class element."); goto end; @@ -1074,8 +1072,8 @@ end: static inline int translate_dynamic_array_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_sequence *fc = fs_sink_ctf_field_class_sequence_create_empty( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_sequence *fc = + fs_sink_ctf_field_class_sequence_create_empty(cur_path_stack_top(ctx)->ir_fc); const bt_field_class *elem_ir_fc = bt_field_class_array_borrow_element_field_class_const(fc->base.base.ir_fc); int ret; @@ -1093,7 +1091,7 @@ static inline int translate_dynamic_array_field_class(struct ctx *ctx) } append_to_parent_field_class(ctx, &fc->base.base); - ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc, &fc->base.base); + ret = cur_path_stack_push(ctx, NULL, false, elem_ir_fc, &fc->base.base); if (ret) { BT_COMP_LOGE_STR("Cannot translate dynamic array field class element."); goto end; @@ -1114,8 +1112,8 @@ end: static inline int translate_bool_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_bool *fc = fs_sink_ctf_field_class_bool_create( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_bool *fc = + fs_sink_ctf_field_class_bool_create(cur_path_stack_top(ctx)->ir_fc); BT_ASSERT(fc); append_to_parent_field_class(ctx, &fc->base.base); @@ -1124,8 +1122,8 @@ static inline int translate_bool_field_class(struct ctx *ctx) static inline int translate_bit_array_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_bit_array *fc = fs_sink_ctf_field_class_bit_array_create( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_bit_array *fc = + fs_sink_ctf_field_class_bit_array_create(cur_path_stack_top(ctx)->ir_fc); BT_ASSERT(fc); append_to_parent_field_class(ctx, &fc->base); @@ -1134,8 +1132,8 @@ static inline int translate_bit_array_field_class(struct ctx *ctx) static inline int translate_integer_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_int *fc = fs_sink_ctf_field_class_int_create( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_int *fc = + fs_sink_ctf_field_class_int_create(cur_path_stack_top(ctx)->ir_fc); BT_ASSERT(fc); append_to_parent_field_class(ctx, &fc->base.base); @@ -1144,8 +1142,8 @@ static inline int translate_integer_field_class(struct ctx *ctx) static inline int translate_real_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_float *fc = fs_sink_ctf_field_class_float_create( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_float *fc = + fs_sink_ctf_field_class_float_create(cur_path_stack_top(ctx)->ir_fc); BT_ASSERT(fc); append_to_parent_field_class(ctx, &fc->base.base); @@ -1154,8 +1152,8 @@ static inline int translate_real_field_class(struct ctx *ctx) static inline int translate_string_field_class(struct ctx *ctx) { - struct fs_sink_ctf_field_class_string *fc = fs_sink_ctf_field_class_string_create( - cur_path_stack_top(ctx)->ir_fc, cur_path_stack_top(ctx)->index_in_parent); + struct fs_sink_ctf_field_class_string *fc = + fs_sink_ctf_field_class_string_create(cur_path_stack_top(ctx)->ir_fc); BT_ASSERT(fc); append_to_parent_field_class(ctx, &fc->base); @@ -1431,11 +1429,11 @@ static int translate_scope_field_class(struct ctx *ctx, bt_field_path_scope scop BT_ASSERT(bt_field_class_get_type(ir_fc) == BT_FIELD_CLASS_TYPE_STRUCTURE); BT_ASSERT(fc); - *fc = &fs_sink_ctf_field_class_struct_create_empty(ir_fc, UINT64_C(-1))->base; + *fc = &fs_sink_ctf_field_class_struct_create_empty(ir_fc)->base; BT_ASSERT(*fc); ctx->cur_scope = scope; BT_ASSERT(ctx->cur_path->len == 0); - ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, ir_fc, NULL); + ret = cur_path_stack_push(ctx, NULL, false, ir_fc, NULL); if (ret) { BT_COMP_LOGE("Cannot translate scope structure field class: " "scope=%d", -- 2.34.1