diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e4b37358b2..5ef3fd83b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -422,9 +422,6 @@ stages: <<: *default_triggering_rules stage: postcheck script: - # Workaround for cppcheck 2.0 uninitvar false positives triggered by (&var)->field syntax - # (see: https://sourceforge.net/p/cppcheck/discussion/general/thread/122153e3c1/) - - sed -i '/^#define ISC__BUFFER.*\\$/{s|_b|__b|;N;s|do {|\0 isc_buffer_t *_b = (isc_buffer_t *)__b;|}; /^#define ISC__BUFFER.*REGION.*\\$/{s|_r|__r|;N;s|do {|\0 isc_region_t *_r = (isc_region_t *)__r;|; /USEDREGION/{s|isc_buffer_t|const \0|g}}' lib/isc/include/isc/buffer.h - *configure - (make -nwk all || true) | compiledb - export GCC_VERSION=$(gcc --version | sed -n 's/.* \([0-9]\+\)\.[0-9]\+\.[0-9]\+.*/\1/p') diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index 81c6cc1037..bb94c98a18 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -362,7 +362,6 @@ main(int argc, char **argv) { setup_logging(mctx, &log); if (predecessor == NULL) { - /* cppcheck-suppress nullPointerRedundantCheck */ if (label == NULL) { fatal("the key label was not specified"); } @@ -384,7 +383,6 @@ main(int argc, char **argv) { isc_result_totext(ret)); } - /* cppcheck-suppress nullPointerRedundantCheck */ if (strchr(label, ':') == NULL) { char *l; int len; @@ -396,13 +394,11 @@ main(int argc, char **argv) { label = l; } - /* cppcheck-suppress nullPointerRedundantCheck */ if (algname == NULL) { fatal("no algorithm specified"); } r.base = algname; - /* cppcheck-suppress nullPointerRedundantCheck */ r.length = strlen(algname); ret = dns_secalg_fromtext(&alg, &r); if (ret != ISC_R_SUCCESS) { diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 30e16fb87f..f16d98257b 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -1180,12 +1180,10 @@ main(int argc, char **argv) { } if (ctx.predecessor == NULL && ctx.policy == NULL) { - /* cppcheck-suppress nullPointerRedundantCheck */ if (algname == NULL) { fatal("no algorithm specified"); } r.base = algname; - /* cppcheck-suppress nullPointerRedundantCheck */ r.length = strlen(algname); ret = dns_secalg_fromtext(&ctx.alg, &r); if (ret != ISC_R_SUCCESS) { diff --git a/bin/dnssec/dnssectool.h b/bin/dnssec/dnssectool.h index bb18c69183..e0970e2ae6 100644 --- a/bin/dnssec/dnssectool.h +++ b/bin/dnssec/dnssectool.h @@ -43,8 +43,12 @@ extern uint8_t dtype[8]; typedef void(fatalcallback_t)(void); +#ifndef CPPCHECK ISC_NORETURN void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); +#else /* CPPCHECK */ +#define fatal(...) exit(1) +#endif void setfatalcallback(fatalcallback_t *callback); diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 82c019168d..f226d156bf 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -1217,11 +1217,6 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { "search for response in bucket %d: %s", bucket, (resp == NULL ? "not found" : "found")); - if (resp == NULL) { - inc_stats(mgr, dns_resstatscounter_mismatch); - free_buffer(disp, ev->region.base, ev->region.length); - goto unlock; - } } else if (resp->id != id || !isc_sockaddr_equal(&ev->address, &resp->host)) { dispatch_log(disp, LVL(90), @@ -1231,6 +1226,12 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { goto unlock; } + if (resp == NULL) { + inc_stats(mgr, dns_resstatscounter_mismatch); + free_buffer(disp, ev->region.base, ev->region.length); + goto unlock; + } + /* * Now that we have the original dispatch the query was sent * from check that the address and port the response was diff --git a/lib/isc/tests/quota_test.c b/lib/isc/tests/quota_test.c index 36b661c3c8..99ba08f75b 100644 --- a/lib/isc/tests/quota_test.c +++ b/lib/isc/tests/quota_test.c @@ -52,19 +52,29 @@ isc_quota_get_set_test(void **state) { isc_quota_destroy("a); } -#define add_quota(quota, quotasp, exp, attached, exp_used) \ - { \ - *quotasp = NULL; \ - isc_result_t result = isc_quota_attach(quota, quotasp); \ - assert_int_equal(result, exp); \ - if (attached) { \ - assert_ptr_equal(*quotasp, quota); \ - } else { \ - assert_null(*quotasp); \ - } \ - assert_int_equal(isc_quota_getused(quota), exp_used); \ +static void +add_quota(isc_quota_t *source, isc_quota_t **target, + isc_result_t expected_result, int expected_used) { + isc_result_t result; + + *target = NULL; + + result = isc_quota_attach(source, target); + assert_int_equal(result, expected_result); + + switch (expected_result) { + case ISC_R_SUCCESS: + case ISC_R_SOFTQUOTA: + assert_ptr_equal(*target, source); + break; + default: + assert_null(*target); + break; } + assert_int_equal(isc_quota_getused(source), expected_used); +} + static void isc_quota_hard_test(void **state) { isc_quota_t quota; @@ -75,18 +85,18 @@ isc_quota_hard_test(void **state) { isc_quota_init("a, 100); for (i = 0; i < 100; i++) { - add_quota("a, "as[i], ISC_R_SUCCESS, true, i + 1); + add_quota("a, "as[i], ISC_R_SUCCESS, i + 1); } - add_quota("a, "as[100], ISC_R_QUOTA, false, 100); + add_quota("a, "as[100], ISC_R_QUOTA, 100); assert_int_equal(isc_quota_getused("a), 100); isc_quota_detach("as[0]); assert_null(quotas[0]); - add_quota("a, "as[100], ISC_R_SUCCESS, true, 100); - add_quota("a, "as[101], ISC_R_QUOTA, false, 100); + add_quota("a, "as[100], ISC_R_SUCCESS, 100); + add_quota("a, "as[101], ISC_R_QUOTA, 100); for (i = 100; i > 0; i--) { isc_quota_detach("as[i]); @@ -108,13 +118,13 @@ isc_quota_soft_test(void **state) { isc_quota_soft("a, 50); for (i = 0; i < 50; i++) { - add_quota("a, "as[i], ISC_R_SUCCESS, true, i + 1); + add_quota("a, "as[i], ISC_R_SUCCESS, i + 1); } for (i = 50; i < 100; i++) { - add_quota("a, "as[i], ISC_R_SOFTQUOTA, true, i + 1); + add_quota("a, "as[i], ISC_R_SOFTQUOTA, i + 1); } - add_quota("a, "as[i], ISC_R_QUOTA, false, 100); + add_quota("a, "as[i], ISC_R_QUOTA, 100); for (i = 99; i >= 0; i--) { isc_quota_detach("as[i]);