]> git.ipfire.org Git - thirdparty/bind9.git/commit
fix: test: Fix a false positive compiler warning/error
authorArаm Sаrgsyаn <aram@isc.org>
Thu, 15 Jan 2026 17:50:33 +0000 (17:50 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Thu, 15 Jan 2026 17:50:33 +0000 (17:50 +0000)
commit9379ee2c1f2eafe782093ae65d3dd36d416a48ce
treef9c123d697823a4e5fd77c5f0c987e864cc97fe7
parent0f7095f39808a68427a748d29a16a770762f544a
parente2994d2b1a2836f24e47a54a0d4c7449f822487b
fix: test: Fix a false positive compiler warning/error

When built with '-Doptimization=1', GCC produces a compiler warning:

    In file included from ../lib/isc/include/isc/lib.h:44,
                     from ../tests/dns/qp_test.c:26:
    ../tests/dns/qp_test.c: In function ‘check_predecessors_withchain’:
    ../lib/isc/include/isc/util.h:182:33: error: ‘ival’ may be used uninitialized [-Werror=maybe-uninitialized]
      182 |         (((a) == (b)) ? (void)0 : (_assert_int_equal(a, b, f, l), abort()))
          |         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/cmocka.h:1234:5: note: in expansion of macro ‘_assert_int_equal’
     1234 |     _assert_int_equal(cast_to_largest_integral_type(a), \
          |     ^~~~~~~~~~~~~~~~~
    ../tests/dns/qp_test.c:859:18: note: ‘ival’ was declared here
      859 |         uint32_t ival;
          |                  ^~~~

This is apparently a false positive, because the qpiter_prev_with_name()
function, when returning ISC_R_SUCCESS, sets the 'ival' (passed to
it by a pointer), and the caller checks that the return value is
ISC_R_SUCCESS before using 'ival'.

Initialize the 'ival' variable to 0 anyway to avoid the build error.

Closes #5704

Merge branch '5704-qp_test-uninitialized-false-positive-error-fix' into 'main'

See merge request isc-projects/bind9!11455