Resolve false positive compilation warning from some GCC versions

The complier claims that 'qresult_type' may be used uninitialized,
though all the cases inside the switch either set the variable
or return from the function, and the warning is generated on a line
after the switch-case block.

Slightly modify the code to set a default value for the variable when
declaring it.

    In function 'rpz_rewrite',
        inlined from 'query_checkrpz' at query.c:7288:12,
        inlined from 'query_gotanswer' at query.c:7724:12:
    query.c:4693:14: error: 'qresult_type' may be used uninitialized [-Werror=maybe-uninitialized]
     4693 |             !dnsrps_set_p(&emsg, client, st, qtype, &rdataset,
          |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     4694 |                           qresult_type != qresult_type_recurse))
          |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    query.c: In function 'query_gotanswer':
    query.c:4268:24: note: 'qresult_type' was declared here
     4268 |         qresult_type_t qresult_type;
          |                        ^~~~~~~~~~~~
    cc1: all warnings being treated as errors
This commit is contained in:
Aram Sargsyan 2025-08-25 10:06:50 +00:00 committed by Arаm Sаrgsyаn
parent 58da549b64
commit 369a350e04

View file

@ -4265,7 +4265,7 @@ rpz_rewrite(ns_client_t *client, dns_rdatatype_t qtype, isc_result_t qresult,
dns_rdataset_t *rdataset = NULL;
dns_fixedname_t nsnamef;
dns_name_t *nsname;
qresult_type_t qresult_type;
qresult_type_t qresult_type = qresult_type_done;
dns_rpz_zbits_t zbits;
isc_result_t result = ISC_R_SUCCESS;
dns_rpz_have_t have;