]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix cppcheck 1.90 warnings
authorMichał Kępień <michal@isc.org>
Wed, 4 Mar 2020 11:41:01 +0000 (12:41 +0100)
committerMichał Kępień <michal@isc.org>
Wed, 4 Mar 2020 11:41:01 +0000 (12:41 +0100)
commit2a01bfd851c0f1ec34a2dbef6551a3dddce4a095
tree9b1346a6145bcf2a4b6708ae739c5a6e71155b21
parentae7c0cca8959b8e46c5ba1ec017bf8095e468e32
Fix cppcheck 1.90 warnings

cppcheck 1.90 reports some false positives for lib/dns/client.c:

    lib/dns/client.c:1431:2: warning: Either the condition 'rctx==((void*)0)' is redundant or there is possible null pointer dereference: rctx. [nullPointerRedundantCheck]
     rctx->rdataset = rdataset;
     ^
    lib/dns/client.c:1416:11: note: Assuming that condition 'rctx==((void*)0)' is not redundant
     if (rctx == NULL)
              ^
    lib/dns/client.c:1415:9: note: Assignment 'rctx=isc__mem_get(mctx,sizeof(*rctx),"lib/dns/client.c",1415)', assigned value is 0
     rctx = isc_mem_get(mctx, sizeof(*rctx));
            ^
    lib/dns/client.c:1431:2: note: Null pointer dereference
     rctx->rdataset = rdataset;
     ^
    lib/dns/client.c:1438:2: warning: Either the condition 'rctx==((void*)0)' is redundant or there is possible null pointer dereference: rctx. [nullPointerRedundantCheck]
     rctx->sigrdataset = sigrdataset;
     ^
    lib/dns/client.c:1416:11: note: Assuming that condition 'rctx==((void*)0)' is not redundant
     if (rctx == NULL)
              ^
    lib/dns/client.c:1415:9: note: Assignment 'rctx=isc__mem_get(mctx,sizeof(*rctx),"lib/dns/client.c",1415)', assigned value is 0
     rctx = isc_mem_get(mctx, sizeof(*rctx));
            ^
    lib/dns/client.c:1438:2: note: Null pointer dereference
     rctx->sigrdataset = sigrdataset;
     ^
    lib/dns/client.c:1445:2: warning: Either the condition 'rctx==((void*)0)' is redundant or there is possible null pointer dereference: rctx. [nullPointerRedundantCheck]
     rctx->client = client;
     ^
    lib/dns/client.c:1416:11: note: Assuming that condition 'rctx==((void*)0)' is not redundant
     if (rctx == NULL)
              ^
    lib/dns/client.c:1415:9: note: Assignment 'rctx=isc__mem_get(mctx,sizeof(*rctx),"lib/dns/client.c",1415)', assigned value is 0
     rctx = isc_mem_get(mctx, sizeof(*rctx));
            ^
    lib/dns/client.c:1445:2: note: Null pointer dereference
     rctx->client = client;
     ^
    lib/dns/client.c:1827:2: warning: Either the condition 'ctx==((void*)0)' is redundant or there is possible null pointer dereference: ctx. [nullPointerRedundantCheck]
     ctx->client = client;
     ^
    lib/dns/client.c:1815:10: note: Assuming that condition 'ctx==((void*)0)' is not redundant
     if (ctx == NULL)
             ^
    lib/dns/client.c:1814:8: note: Assignment 'ctx=isc__mem_get(client->mctx,sizeof(*ctx),"lib/dns/client.c",1814)', assigned value is 0
     ctx = isc_mem_get(client->mctx, sizeof(*ctx));
           ^
    lib/dns/client.c:1827:2: note: Null pointer dereference
     ctx->client = client;
     ^

All of them are caused by cppcheck not recognizing the relationship
between isc_mem_get() returning NULL and the result variable being set
to ISC_R_NOMEMORY (with a subsequent jump to a cleanup section).

Move "goto cleanup;" statements into error handling branches to prevent
cppcheck from generating these warnings.
lib/dns/client.c