Fix: shadowed variables
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 18 Oct 2019 19:31:08 +0000 (15:31 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 22 Oct 2019 21:44:21 +0000 (17:44 -0400)
This fixes some shadowing of variable across the project, as reported by
the gcc option `-Werror=shadow=local`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I93820a4fc14e25ed514c6a05bd30ae4c86216326
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2221
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/bindings/python/bt2/bt2/native_bt_autodisc.i.h
src/cli/babeltrace2-cfg-cli-args.c
src/cli/babeltrace2.c
src/ctf-writer/fields.c
src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c
src/plugins/text/details/write.c
src/plugins/utils/trimmer/trimmer.c

index 9dcacddf0c52eb4201dfab50e67ba2135f639bb0..aac92e129031fe77f2e26a01b583b5010e27506e 100644 (file)
@@ -127,7 +127,7 @@ bt_value *bt_bt2_auto_discover_source_components(const bt_value *inputs,
        }
 
        for (i = 0; i < auto_disc.results->len; i++) {
-               struct auto_source_discovery_result *result =
+               struct auto_source_discovery_result *autodisc_result =
                        g_ptr_array_index(auto_disc.results, i);
                bt_value_array_append_element_status append_element_status;
 
@@ -140,7 +140,7 @@ bt_value *bt_bt2_auto_discover_source_components(const bt_value *inputs,
                }
 
                append_element_status = bt_value_array_append_string_element(
-                       component_info, result->plugin_name);
+                       component_info, autodisc_result->plugin_name);
                if (append_element_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                        BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
                                "Failed to append one array element.");
@@ -149,7 +149,7 @@ bt_value *bt_bt2_auto_discover_source_components(const bt_value *inputs,
                }
 
                append_element_status = bt_value_array_append_string_element(
-                       component_info, result->source_cc_name);
+                       component_info, autodisc_result->source_cc_name);
                if (append_element_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                        BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
                                "Failed to append one array element.");
@@ -158,7 +158,7 @@ bt_value *bt_bt2_auto_discover_source_components(const bt_value *inputs,
                }
 
                append_element_status = bt_value_array_append_element(
-                       component_info, result->inputs);
+                       component_info, autodisc_result->inputs);
                if (append_element_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                        BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
                                "Failed to append one array element.");
@@ -167,7 +167,7 @@ bt_value *bt_bt2_auto_discover_source_components(const bt_value *inputs,
                }
 
                append_element_status = bt_value_array_append_element(
-                       component_info, result->original_input_indices);
+                       component_info, autodisc_result->original_input_indices);
                if (append_element_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
                        BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name,
                                "Failed to append one array element.");
index c6401e1085f65563fe02bbe60877289b4953dc35..ae8e8eef3f2fe9d3bae984e06007b9b2e18383c7 100644 (file)
@@ -2611,7 +2611,6 @@ int bt_value_to_cli_param_value_append(const bt_value *value, GString *buf)
                uint64_t sz = bt_value_array_get_length(value);
                for (uint64_t i = 0; i < sz; i++) {
                        const bt_value *item;
-                       int ret;
 
                        if (i > 0) {
                                g_string_append(buf, ", ");
index 378fff8a1c9f2e52da6bb6b04c3fd34450109bb9..80082d07d78e95e25c2e14ab2e839fd92476fc52 100644 (file)
@@ -335,7 +335,6 @@ void print_value_rec(FILE *fp, const bt_value *value, size_t indent)
        double dbl_val;
        const char *str_val;
        int size;
-       int i;
        GPtrArray *map_keys = NULL;
 
        if (!value) {
@@ -378,6 +377,8 @@ void print_value_rec(FILE *fp, const bt_value *value, size_t indent)
                        bt_common_color_reset());
                break;
        case BT_VALUE_TYPE_ARRAY:
+       {
+               guint i;
                size = bt_value_array_get_length(value);
                if (size < 0) {
                        goto error;
@@ -420,6 +421,7 @@ void print_value_rec(FILE *fp, const bt_value *value, size_t indent)
                        print_value_rec(fp, element, indent + 2);
                }
                break;
+       }
        case BT_VALUE_TYPE_MAP:
        {
                guint i;
index 53ce8b60ac447126effcafa998cb7c9656da770f..ce2c3739f661239662c40b77272903f320396c99 100644 (file)
@@ -91,19 +91,19 @@ int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
 
        /* Create all fields contained in the structure field. */
        for (i = 0; i < structure_type->fields->len; i++) {
-               struct bt_ctf_field_common *field;
+               struct bt_ctf_field_common *member_field;
                struct bt_ctf_field_type_common_structure_field *struct_field =
                        BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
                                structure_type, i);
-               field = field_create_func(struct_field->type);
-               if (!field) {
+               member_field = field_create_func(struct_field->type);
+               if (!member_field) {
                        BT_LOGE("Failed to create structure field's member: name=\"%s\", index=%zu",
                                g_quark_to_string(struct_field->name), i);
                        ret = -1;
                        goto end;
                }
 
-               g_ptr_array_index(structure->fields, i) = field;
+               g_ptr_array_index(structure->fields, i) = member_field;
        }
 
        BT_LOGD("Initialized common structure field object: addr=%p, ft-addr=%p",
@@ -142,20 +142,20 @@ int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
 
        /* Create all fields contained in the variant field. */
        for (i = 0; i < variant_type->choices->len; i++) {
-               struct bt_ctf_field_common *field;
+               struct bt_ctf_field_common *member_field;
                struct bt_ctf_field_type_common_variant_choice *var_choice =
                        BT_CTF_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
                                variant_type, i);
 
-               field = field_create_func(var_choice->type);
-               if (!field) {
+               member_field = field_create_func(var_choice->type);
+               if (!member_field) {
                        BT_LOGE("Failed to create variant field's member: name=\"%s\", index=%zu",
                                g_quark_to_string(var_choice->name), i);
                        ret = -1;
                        goto end;
                }
 
-               g_ptr_array_index(variant->fields, i) = field;
+               g_ptr_array_index(variant->fields, i) = member_field;
        }
 
        BT_LOGD("Initialized common variant field object: addr=%p, ft-addr=%p",
index a975be3789c422e003d1fc2f9f9dda9c236dce3c..73b9f34b82cea32a297be77e598f17247fc0e154 100644 (file)
@@ -481,14 +481,14 @@ void append_struct_field_class_members(struct ctx *ctx,
                                ctx->indent_level++;
 
                                for (i = 0; i < var_fc->options->len; i++) {
-                                       struct fs_sink_ctf_named_field_class *named_fc =
+                                       struct fs_sink_ctf_named_field_class *option_named_fc =
                                                fs_sink_ctf_field_class_variant_borrow_option_by_index(
                                                        var_fc, i);
 
                                        append_indent(ctx);
                                        g_string_append_printf(ctx->tsdl,
                                                "\"%s\" = %" PRIu64 ",\n",
-                                               named_fc->name->str, i);
+                                               option_named_fc->name->str, i);
                                }
 
                                append_end_block(ctx);
index 4eb4f9f8a29c048010eefc2b331762bbf642c188..7b52335c817c733927bfa7139ceb86839fa726cc 100644 (file)
@@ -1103,17 +1103,17 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
                                const bt_field_class_structure_member *member =
                                        bt_field_class_structure_borrow_member_by_index_const(
                                                fc, i);
-                               const bt_value *user_attrs;
+                               const bt_value *member_user_attrs;
                                const bt_field_class *member_fc =
                                        bt_field_class_structure_member_borrow_field_class_const(member);
 
                                write_nl(ctx);
                                write_compound_member_name(ctx,
                                        bt_field_class_structure_member_get_name(member));
-                               user_attrs = bt_field_class_structure_member_borrow_user_attributes_const(
+                               member_user_attrs = bt_field_class_structure_member_borrow_user_attributes_const(
                                        member);
 
-                               if (bt_value_map_is_empty(user_attrs)) {
+                               if (bt_value_map_is_empty(member_user_attrs)) {
                                        write_sp(ctx);
                                        write_field_class(ctx, member_fc);
                                } else {
@@ -1127,7 +1127,7 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
                                        write_nl(ctx);
 
                                        /* User attributes */
-                                       write_user_attributes(ctx, user_attrs,
+                                       write_user_attributes(ctx, member_user_attrs,
                                                false, NULL);
 
                                        decr_indent(ctx);
@@ -1173,7 +1173,6 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
                if (ranges) {
                        GArray *sorted_ranges = range_set_to_int_ranges(
                                ranges, selector_is_signed);
-                       uint64_t i;
 
                        BT_ASSERT_DBG(sorted_ranges);
                        BT_ASSERT_DBG(sorted_ranges->len > 0);
@@ -2053,7 +2052,6 @@ gint compare_streams(const bt_stream **a, const bt_stream **b)
 static
 void write_trace(struct details_write_ctx *ctx, const bt_trace *trace)
 {
-       const char *name;
        GPtrArray *streams = g_ptr_array_new();
        uint64_t i;
        bool printed_prop = false;
@@ -2065,7 +2063,7 @@ void write_trace(struct details_write_ctx *ctx, const bt_trace *trace)
 
        /* Write name */
        if (ctx->details_comp->cfg.with_trace_name) {
-               name = bt_trace_get_name(trace);
+               const char *name = bt_trace_get_name(trace);
                if (name) {
                        g_string_append(ctx->str, " `");
                        write_str_prop_value(ctx, name);
index 889845a1d6fdde2ccb7cb1f53151625fe138cc57..36d1439abbae4482c65611c00736c7d546136029 100644 (file)
@@ -974,8 +974,6 @@ state_set_trimmer_iterator_bounds(
                for (i = 0; i < count; i++) {
                        const bt_message *msg = msgs[i];
                        bool has_ns_from_origin;
-                       int ret;
-
                        ret = get_msg_ns_from_origin(msg, &ns_from_origin,
                                &has_ns_from_origin);
                        if (ret) {
This page took 0.031865 seconds and 4 git commands to generate.