summaryrefslogtreecommitdiff
path: root/meta-openembedded/meta-oe/recipes-extended/pmdk/files/0001-examples-Initialize-child_idx.patch
blob: 8e2b3c7cbbd5a4b44130aa4895912b6b62a4ab4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 721a48e5397bd4ab454482041e55671eae7b189f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 11 May 2020 18:01:11 -0700
Subject: [PATCH] examples: Initialize child_idx

Assign UINT_MAX and assert it

Fixes warning
rtree_map.c:358:12: error: 'child_idx' may be used uninitialized
in this function [-Werror=maybe-uninitialized]

Upstream-Status: Submitted [https://github.com/pmem/pmdk/pull/4802]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 src/examples/libpmemobj/tree_map/rtree_map.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/examples/libpmemobj/tree_map/rtree_map.c b/src/examples/libpmemobj/tree_map/rtree_map.c
index 995e22bb9..6b3ead65c 100644
--- a/src/examples/libpmemobj/tree_map/rtree_map.c
+++ b/src/examples/libpmemobj/tree_map/rtree_map.c
@@ -8,6 +8,7 @@
 #include <ex_common.h>
 #include <assert.h>
 #include <errno.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <stdbool.h>
 
@@ -320,12 +321,13 @@ has_only_one_child(TOID(struct tree_map_node) node, unsigned *child_idx)
 static void
 remove_extra_node(TOID(struct tree_map_node) *node)
 {
-	unsigned child_idx;
+	unsigned child_idx = UINT_MAX;
 	TOID(struct tree_map_node) tmp, tmp_child;
 
 	/* Our node has child with only one child. */
 	tmp = *node;
 	has_only_one_child(tmp, &child_idx);
+	assert(child_idx != UINT_MAX);
 	tmp_child = D_RO(tmp)->slots[child_idx];
 
 	/*
-- 
2.26.2