misc: Add twalk_r function

Message ID 87o94kvl32.fsf@oldenburg2.str.redhat.com
State Superseded
Headers

Commit Message

Florian Weimer May 2, 2019, 5:10 p.m. UTC
  * Joseph Myers:

> I'm seeing (at least with GCC 8):
>
> tst-tsearch.c: In function 'walk_tree.constprop':
> tst-tsearch.c:231:3: error: 'first_list_size' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    for (size_t i = 0; i < first_list_size && i < walk_trace_size (&walk_trace);
>    ^~~

Huh.  Sorry about that.  I don't get this error, with a GCC 8.3-based
compiler.

It's arguably a test bug.  Does this patch fix it for you?

It assumes that the tree is not empty, but I think this is true in this
test.

Thanks,
Florian
  

Comments

Joseph Myers May 2, 2019, 8 p.m. UTC | #1
On Thu, 2 May 2019, Florian Weimer wrote:

> It's arguably a test bug.  Does this patch fix it for you?

Yes, this fixes the testsuite build.
  

Patch

diff --git a/misc/tst-tsearch.c b/misc/tst-tsearch.c
index 9a570dd6c9..07d13622b1 100644
--- a/misc/tst-tsearch.c
+++ b/misc/tst-tsearch.c
@@ -223,6 +223,7 @@  walk_tree (void *root, int expected_count)
   size_t first_list_size;
   struct walk_trace_element *first_list
     = walk_trace_finalize (&walk_trace, &first_list_size);
+  TEST_VERIFY_EXIT (first_list != NULL);
 
   walk_tree_with (root, expected_count, twalk_with_twalk_r);