Fix: uninitialized variable may be used warning
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Nov 2017 15:55:16 +0000 (10:55 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Nov 2017 15:58:31 +0000 (10:58 -0500)
gcc 7.2 warns of potentially uninitialized variables being
used as the callers rely on output parameters being
initialized by the callees on error. This behaviour is not
specified as part of the API so relying on this is iffy.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/ctf-ir/field-types.c
plugins/ctf/common/metadata/visitor-generate-ir.c

index a6ebdb391d8f9591bb92d19f749a7ba1191e71a7..c2a5383ccc86cb71f8d5f602c7cfee7dc46f2b41 100644 (file)
@@ -2977,7 +2977,7 @@ int bt_field_type_get_alignment(struct bt_field_type *type)
                assert(element_count >= 0);
 
                for (i = 0; i < element_count; i++) {
-                       struct bt_field_type *field;
+                       struct bt_field_type *field = NULL;
                        int field_alignment;
 
                        ret = bt_field_type_structure_get_field_by_index(
index aae7322bc8b21069c442ea99805c605f0bb693a7..734ed996840b144b9f9844eebe1169ae8662bbe4 100644 (file)
@@ -3258,7 +3258,7 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
 
                        _SET(set, _EVENT_NAME_SET);
                } else if (!strcmp(left, "id")) {
-                       int64_t id;
+                       int64_t id = -1;
 
                        if (_IS_SET(set, _EVENT_ID_SET)) {
                                _BT_LOGE_DUP_ATTR(node, "id",
@@ -4873,7 +4873,7 @@ int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
                g_free(right);
                _SET(set, _CLOCK_DESCRIPTION_SET);
        } else if (!strcmp(left, "freq")) {
-               uint64_t freq;
+               uint64_t freq = -1ULL;
 
                if (_IS_SET(set, _CLOCK_FREQ_SET)) {
                        _BT_LOGE_DUP_ATTR(entry_node, "freq", "clock class");
This page took 0.027978 seconds and 4 git commands to generate.