BUILD: resolvers: avoid a possible warning on null-deref
authorWilly Tarreau <w@1wt.eu>
Wed, 20 Oct 2021 15:29:28 +0000 (17:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 20 Oct 2021 15:53:35 +0000 (17:53 +0200)
commit10c1a8c3bd6a24f51616172a37f1e3ef58f8fa84
tree77488cc84721dd674e4726e3caa9713d8a364af8
parent2acc160c05c0c8dc28ecce5941451c916d29bc63
BUILD: resolvers: avoid a possible warning on null-deref

Depending on the code that precedes the loop, gcc may emit this warning:

  src/resolvers.c: In function 'resolv_process_responses':
  src/resolvers.c:1009:11: warning: potential null pointer dereference [-Wnull-dereference]
   1009 |  if (query->type != DNS_RTYPE_SRV && flags & DNS_FLAG_TRUNCATED) {
        |      ~~~~~^~~~~~

However after carefully checking, r_res->header.qdcount it exclusively 1
when reaching this place, which forces the for() loop to enter for at
least one iteration, and <query> to be set. Thus there's no code path
leading to a null deref. It's possibly just because the assignment is
too far and the compiler cannot figure that the condition is always OK.
Let's just mark it to please the compiler.
src/resolvers.c