tests/string: fix false-positive uninitialized val

GCC 14.2 with debugoptimized build complained:

In file included from ../../git/weston/tests/weston-test-assert.h:32,
                 from ../../git/weston/tests/string-test.c:36:
In function ‘strtof_conversions’,
    inlined from ‘wrapstrtof_conversions’ at ../../git/weston/tests/string-test.c:92:1:
../../git/weston/shared/weston-assert.h:60:12: error: ‘val’ may be used uninitialized [-Werror=maybe-uninitialized]
   60 |         if (!cond)                                                              \
      |            ^
../../git/weston/tests/weston-test-assert.h:153:34: note: in expansion of macro ‘weston_assert_’
  153 | #define test_assert_f32_eq(a, b) weston_assert_(NULL, a, b, float, "%.10g", ==)
      |                                  ^~~~~~~~~~~~~~
../../git/weston/tests/string-test.c:97:9: note: in expansion of macro ‘test_assert_f32_eq’
   97 |         test_assert_f32_eq(val, 0.0);
      |         ^~~~~~~~~~~~~~~~~~
../../git/weston/tests/string-test.c: In function ‘wrapstrtof_conversions’:
../../git/weston/tests/string-test.c:94:15: note: ‘val’ was declared here
   94 |         float val;
      |               ^~~

The debug build did not complain.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2025-12-16 13:23:16 +02:00 committed by Marius Vlad
parent 6af97ec150
commit 2e66195546

View file

@ -91,7 +91,7 @@ TEST(strtol_conversions)
TEST(strtof_conversions)
{
float val;
float val = NAN;
test_assert_true(safe_strtofloat("0.0", &val));
test_assert_f32_eq(val, 0.0);