]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a false positive compiler warning/error
authorAram Sargsyan <aram@isc.org>
Thu, 15 Jan 2026 11:26:47 +0000 (11:26 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Thu, 15 Jan 2026 17:49:29 +0000 (17:49 +0000)
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.

tests/dns/qp_test.c

index 945c19901f63af930017c111428e2f9957440344..31d10e9501c23975193cfe3d7a43cd3b26758e63 100644 (file)
@@ -856,7 +856,7 @@ check_predecessors_withchain(dns_qp_t *qp, struct check_predecessors check[],
        dns_name_t *name = dns_fixedname_initname(&fn1);
        dns_name_t *pred = dns_fixedname_initname(&fn2);
        char *namestr = NULL;
-       uint32_t ival;
+       uint32_t ival = 0;
 
        for (int i = 0; check[i].query != NULL; i++) {
                dns_qpiter_t it;