From 11476be369af3c9e283803c64c494f21dfc79e06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 3 May 2019 16:23:16 -0400 Subject: [PATCH] Fix: uninitialized variant fc in set_field_refs() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit GCC 8.3.0 emits the following warning: translate-trace-ir-to-ctf-ir.c:935:16: warning: ‘var_fc’ may be used uninitialized in this function [-Wmaybe-uninitialized] named_fc = fs_sink_ctf_field_class_variant_borrow_option_by_index( ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var_fc, i); I don't think this "condition" is reachable, but it is, in principle possible. Initializing var_fc to NULL silences this warning. Signed-off-by: Jérémie Galarneau Change-Id: I1fd8951778e8b3705974324e1cd5d87892c2e418 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1251 Reviewed-by: Francis Deslauriers --- plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c b/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c index 4d740139..699b3a5b 100644 --- a/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c +++ b/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c @@ -912,7 +912,7 @@ int set_field_refs(struct fs_sink_ctf_field_class * const fc, uint64_t i; uint64_t len; struct fs_sink_ctf_field_class_struct *struct_fc; - struct fs_sink_ctf_field_class_variant *var_fc; + struct fs_sink_ctf_field_class_variant *var_fc = NULL; struct fs_sink_ctf_named_field_class *named_fc; if (fc_type == FS_SINK_CTF_FIELD_CLASS_TYPE_STRUCT) { -- 2.34.1