Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | puzzles: avoid compiler unitialized variable error |
| 2 | |
| 3 | The compiler does not realize that we must go through the while() |
| 4 | loop at least once, so we replace it with a for() loop. |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | |
| 8 | Signed-off-by: Joe Slater <joe.slater@windriver.com> |
| 9 | |
| 10 | --- a/tree234.c |
| 11 | +++ b/tree234.c |
| 12 | @@ -326,8 +326,11 @@ static void *add234_internal(tree234 *t, |
| 13 | return orig_e; |
| 14 | } |
| 15 | |
| 16 | - n = t->root; |
| 17 | - while (n) { |
| 18 | + /* |
| 19 | + * We know t->root is not NULL. The logic |
| 20 | + * to break out of this is at the end of the loop. |
| 21 | + */ |
| 22 | + for (n = t->root;;) { |
| 23 | LOG((" node %p: %p/%d \"%s\" %p/%d \"%s\" %p/%d \"%s\" %p/%d\n", |
| 24 | n, |
| 25 | n->kids[0], n->counts[0], n->elems[0], |