puzzles: fix uninitialized variable compiler error
PATCH 1/1 puzzles: fix uninitialized variable compiler error
In tree234.c, change a while() loop to a for() loop so that the compiler will realize we loop at least once.
--- .../puzzles/files/fix-ki-uninitialized.patch | 25 ++++++++++++++++++++++ meta/recipes-sato/puzzles/puzzles_git.bb | 1 + 2 files changed, 26 insertions(+) create mode 100644 meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch
meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch new file +25 -0
@@ -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 <[email protected]> + +--- 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],
meta/recipes-sato/puzzles/puzzles_git.bb +1 -0
@@ -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"
Signature · 1 line
2.7.4
Can we *please* start sending these upstream. It's not like the maintainer isn't responsive.
Ross
Quoted 62 lines · Joe Slater
In
tree234.c, change awhile()loop to afor()loop so that the compiler will realize we loop at least once.Signed-off-by Joe Slater <[email protected]>--- .../puzzles/files/fix-ki-uninitialized.patch | 25 ++++++++++++++++++++++ meta/recipes-sato/puzzles/puzzles_git.bb | 1 + 2 files changed, 26 insertions(+) create mode 100644 meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patchmeta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch new file +25
-0@@ -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 <[email protected]> + +--- 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],meta/recipes-sato/puzzles/puzzles_git.bb +1
-1@@ -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" --2.7.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Quoted 2 lines · Ross
Can we *please* start sending these upstream. It's not like the maintainer isn't responsive.
This would also help to get such patches properly reviewed.
Quoted 7 lines
Ross
On Thu, 14 Mar 2019 at 19:20, Joe Slater <[email protected]> wrote:
...Quoted 2 lines
meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch new file +2
-0+The compiler does not realize that we must go through the while() +loop at least once, so we replace it with a for() loop....
Quoted 8 lines
Quoted 7 lines
+- 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;;) {...
This is the second patch this week where I don't see why a "fix" should make any difference.
The code immediately above is:
if (t->root == NULL) {
...
return orig_e;)
The submitter did not provide information how to reproduce, but when I try to reproduce the problem on amd64 it happens only with -Og (due to puzzles upstream building with -Werror).
This would also explain why such patches suddenly start getting submitted - 2 weeks ago DEBUG_OPTIMIZATION was changed from -O to -Og.
-Werror is added after the passed CFLAGS so adding -Wno-error globally would not help here, but a non-upstreamable patch to remove the -Werror looks more correct here as a short-term workaround.
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 4 lines · Adrian Bunk
...
but when I try to reproduce the problem on amd64 it happens only with -Og (due to puzzles upstream building with -Werror).
...
For the root cause I filed
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89723
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 2 lines · Adrian Bunk
For the root cause I filed
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89723
Cookie for Mr Bunk! Thanks.
Ross
Quoted 29 lines · Joe Slater
In
tree234.c, change awhile()loop to afor()loop so that the compiler will realize we loop at least once.Signed-off-by Joe Slater <[email protected]>--- .../puzzles/files/fix-ki-uninitialized.patch | 25 ++++++++++++++++++++++ meta/recipes-sato/puzzles/puzzles_git.bb | 1 + 2 files changed, 26 insertions(+) create mode 100644 meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patchmeta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch new file +12
-0@@ -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 <[email protected]> + +--- a/tree234.c ++++ b/tree234.c +@@ -326,8 +326,11 @@ static void *add234_internal(tree234 *t,
meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch line 22
Quoted 10 lines
meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch new file +10
-0+ 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;;) {
may do .. while () is better
Quoted 23 lines
meta/recipes-sato/puzzles/files/fix-ki-uninitialized.patch new file +3
-0+ 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],meta/recipes-sato/puzzles/puzzles_git.bb +1
-1@@ -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" --2.7.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core