Fix -Wjump-misses-init warnings
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 28 Oct 2019 00:27:48 +0000 (20:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Oct 2019 19:14:53 +0000 (15:14 -0400)
Fix gcc warnings of this kind:

      CC       stream-class.lo
    /home/simark/src/babeltrace/src/ctf-writer/stream-class.c: In function ‘bt_ctf_stream_class_common_add_event_class’:
    /home/simark/src/babeltrace/src/ctf-writer/stream-class.c:177:3: error: jump skips variable initialization [-Werror=jump-misses-init]
      177 |   goto end;
          |   ^~~~
    /home/simark/src/babeltrace/src/ctf-writer/stream-class.c:389:1: note: label ‘end’ defined here
      389 | end:
          | ^~~
    /home/simark/src/babeltrace/src/ctf-writer/stream-class.c:241:29: note: ‘query’ declared here
      241 |  struct bt_ctf_search_query query = { .value = event_class, .found = 0 };
          |                             ^~~~~

Fix it by moving the declarations near the top, as our coding style
prescribes.

Change-Id: I49209e40894a362f84c413e50640ea62ff040de4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2267
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
configure.ac
src/ctf-writer/stream-class.c
src/plugins/ctf/common/msg-iter/msg-iter.c
src/plugins/ctf/fs-sink/fs-sink-trace.c

index 72d77cba75809d9819431827ce016819e9cf2bc3..17df88d33123bb378c9073eb693a849085044ea4 100644 (file)
@@ -678,7 +678,6 @@ AX_COMPILER_FLAGS(
                -Wno-logical-op dnl
                -Wno-shadow dnl
                -Wno-null-dereference dnl
-               -Wno-jump-misses-init dnl
                -Wno-double-promotion dnl
                -Wno-cast-align dnl
        ])
index 55f3a09b851a8ab8e0855cd224feefc73892312b..6c7bdd183e204e3295d4509ca98251a53076b243 100644 (file)
@@ -166,6 +166,7 @@ int bt_ctf_stream_class_common_add_event_class(
        const enum bt_ctf_validation_flag validation_flags =
                BT_CTF_VALIDATION_FLAG_EVENT;
        struct bt_ctf_clock_class *expected_clock_class = NULL;
+       struct bt_ctf_search_query query = { .value = event_class, .found = 0 };
 
        BT_ASSERT_DBG(copy_field_type_func);
 
@@ -238,7 +239,6 @@ int bt_ctf_stream_class_common_add_event_class(
        }
 
        /* Check for duplicate event classes */
-       struct bt_ctf_search_query query = { .value = event_class, .found = 0 };
        g_ptr_array_foreach(stream_class->event_classes, event_class_exists,
                &query);
        if (query.found) {
index de7e594ff74382a9973a8ef6e6a76b1338135154..30552ae0bdd2070b691bf411cc9797aa30c71cf2 100644 (file)
@@ -2093,6 +2093,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value,
        enum bt_bfcr_status status = BT_BFCR_STATUS_OK;
        bt_field *field = NULL;
        struct bt_msg_iter *notit = data;
+       bt_field_class_type type;
 
        BT_COMP_LOGT("Floating point number function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
@@ -2104,7 +2105,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value,
        }
 
        field = borrow_next_field(notit);
-       bt_field_class_type type = bt_field_get_class_type(field);
+       type = bt_field_get_class_type(field);
        BT_ASSERT_DBG(field);
        BT_ASSERT_DBG(bt_field_borrow_class_const(field) == fc->ir_fc);
        BT_ASSERT_DBG(bt_field_class_type_is(type, BT_FIELD_CLASS_TYPE_REAL));
index b64c62ed3fc2cb0076e1dd8184e09c7e6c2ca5b6..1bc01d2fe8755e6430993792899bd081acdd6ede 100644 (file)
@@ -407,6 +407,7 @@ static
 GString *make_trace_path_rel(const struct fs_sink_trace *trace)
 {
        GString *path = NULL;
+       const char *trace_name;
 
        if (trace->fs_sink->assume_single_trace) {
                /* Use output directory directly */
@@ -421,7 +422,7 @@ GString *make_trace_path_rel(const struct fs_sink_trace *trace)
        }
 
        /* Otherwise, use the trace name, if available. */
-       const char *trace_name = bt_trace_get_name(trace->ir_trace);
+       trace_name = bt_trace_get_name(trace->ir_trace);
        if (trace_name) {
                path = g_string_new(trace_name);
                goto end;
This page took 0.027697 seconds and 4 git commands to generate.