From: Simon Marchi Date: Mon, 28 Oct 2019 00:27:48 +0000 (-0400) Subject: Fix -Wjump-misses-init warnings X-Git-Tag: v2.0.0-rc2~36 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=100acf4a8f40dc60afaaaa788ed94118e1e93d43 Fix -Wjump-misses-init warnings 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2267 Reviewed-by: Francis Deslauriers --- diff --git a/configure.ac b/configure.ac index 72d77cba..17df88d3 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ]) diff --git a/src/ctf-writer/stream-class.c b/src/ctf-writer/stream-class.c index 55f3a09b..6c7bdd18 100644 --- a/src/ctf-writer/stream-class.c +++ b/src/ctf-writer/stream-class.c @@ -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) { diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.c b/src/plugins/ctf/common/msg-iter/msg-iter.c index de7e594f..30552ae0 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.c +++ b/src/plugins/ctf/common/msg-iter/msg-iter.c @@ -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)); diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.c b/src/plugins/ctf/fs-sink/fs-sink-trace.c index b64c62ed..1bc01d2f 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.c +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.c @@ -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;