]> code.ossystems Code Review - openembedded-core.git/commitdiff
puzzles: fix uninitialized variable compiler error
authorJoe Slater <joe.slater@windriver.com>
Thu, 14 Mar 2019 19:19:24 +0000 (12:19 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 18 Mar 2019 22:59:59 +0000 (22:59 +0000)
In tree234.c, change a while() loop to a for() loop so
that the compiler will realize we loop at least once.

Signed-off-by: Joe Slater <joe.slater@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch [new file with mode: 0644]
meta/recipes-sato/puzzles/puzzles_git.bb

diff --git a/meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch b/meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch
new file mode 100644 (file)
index 0000000..7218d62
--- /dev/null
@@ -0,0 +1,25 @@
+puzzles: avoid compiler unitialized variable error
+
+The compiler does not realize that we must go through the while()
+loop at least once, so we replace it with a for() loop.
+
+Upstream-Status: Pending
+
+Signed-off-by: Joe Slater <joe.slater@windriver.com>
+
+--- a/tree234.c
++++ b/tree234.c
+@@ -326,8 +326,11 @@ static void *add234_internal(tree234 *t,
+       return orig_e;
+     }
+-    n = t->root;
+-    while (n) {
++    /*
++     * We know t->root is not NULL.  The logic
++     * to break out of this is at the end of the loop.
++     */
++    for (n = t->root;;) {
+       LOG(("  node %p: %p/%d \"%s\" %p/%d \"%s\" %p/%d \"%s\" %p/%d\n",
+            n,
+            n->kids[0], n->counts[0], n->elems[0],
index 0766bd4ff1061a640856b2e425a9dfa73a5deabf..59b952522dffb8be027d7110b2c90793d1dd967b 100644 (file)
@@ -14,6 +14,7 @@ SRC_URI = "git://git.tartarus.org/simon/puzzles.git \
            file://0001-palisade-Fix-warnings-with-clang-on-arm.patch \
            file://0001-Use-Wno-error-format-overflow-if-the-compiler-suppor.patch \
            file://0001-pattern.c-Change-string-lenght-parameter-to-be-size_.patch \
+           file://fix-ki-uninitialized.patch \
            "
 
 UPSTREAM_CHECK_COMMITS = "1"