diff --git a/.dir-locals.el b/.dir-locals.el index 9c8d101f7f..1871abc8cb 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -106,8 +106,9 @@ "--enable=all" "--suppress=missingIncludeSystem" "--suppress=nullPointerRedundantCheck" - (concat "--suppressions-list=" (expand-file-name - (concat directory-of-current-dir-locals-file "util/suppressions.txt"))) + "--suppress=preprocessorErrorDirective" + "--suppress=unknownMacro" + "--suppress=unmatchedSuppression" (concat "-include=" (expand-file-name (concat directory-of-current-dir-locals-file "config.h"))) ) diff --git a/.gitignore b/.gitignore index 839e5452df..0c7e7a9bab 100644 --- a/.gitignore +++ b/.gitignore @@ -62,8 +62,6 @@ timestamp /compile_commands.json # Gets generated by Build Ear (bear) /compile_commands.commands.json -/cppcheck_html/ -/cppcheck.results /tsan /util/check-make-install /INSTALL diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1167c3e4f7..5b6a276580 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -382,34 +382,6 @@ stages: - tsan/ when: on_failure -.cppcheck_args: &run_cppcheck - - cppcheck --enable=warning,performance,portability,information,missingInclude --include=config.h --std=c11 --language=c --project=compile_commands.json --error-exitcode=2 -j ${TEST_PARALLEL_JOBS:-1} --xml --output-file=cppcheck.results --relative-paths="$CI_PROJECT_DIR" --inline-suppr --suppressions-list=util/suppressions.txt - -.cppcheck_report: &cppcheck_report_html - - cppcheck-htmlreport --title="BIND 9 ($CI_COMMIT_SHORT_SHA) Cppcheck Report" --file=cppcheck.results --report-dir=cppcheck_html/ - -.cppcheck: &cppcheck_job - <<: *default_triggering_rules - stage: postcheck - script: - - *configure - - (make -nwk all || true) | compiledb - - export GCC_VERSION=$(gcc --version | sed -n 's/.* \([0-9]\+\)\.[0-9]\+\.[0-9]\+.*/\1/p') - - sed -i "/gcc\",/a\"-DCPPCHECK\", \"-D__STDC__\", \"-D__GNUC__=${GCC_VERSION}\"," compile_commands.json - - *run_cppcheck - after_script: - - *cppcheck_report_html - artifacts: - paths: - - compile_commands.json - - cppcheck.results - - cppcheck_html/ - expire_in: "1 day" - when: on_failure - needs: - - job: autoreconf - artifacts: true - ### Job Definitions # Jobs in the precheck stage @@ -788,10 +760,6 @@ unit:gcc:sid:amd64: - job: gcc:sid:amd64 artifacts: true -cppcheck: - <<: *base_image - <<: *cppcheck_job - # Job for out-of-tree GCC build on Debian "sid" (amd64) # Also tests configration option: --with-lmdb. diff --git a/CHANGES b/CHANGES index e13e6cc56b..25e3094104 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +5779. [test] Drop cppcheck suppressions and workarounds. [GL #2886] + 5778. [bug] Destroyed TLS contexts could have been used after a reconfiguration, making BIND unable to serve queries over TLS and HTTPS. [GL #3053] diff --git a/bin/dnssec/dnssectool.h b/bin/dnssec/dnssectool.h index 7694f362c0..8830eb7603 100644 --- a/bin/dnssec/dnssectool.h +++ b/bin/dnssec/dnssectool.h @@ -41,12 +41,8 @@ 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/rbt.c b/lib/dns/rbt.c index fa31109431..4f28423527 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -2135,8 +2135,6 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) { * Fix color violations. */ if (IS_BLACK(item)) { - /* cppcheck-suppress nullPointerRedundantCheck symbolName=item - */ parent = PARENT(item); while (child != *rootp && IS_BLACK(child)) { @@ -2154,8 +2152,6 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) { INSIST(sibling != NULL); - /* cppcheck-suppress nullPointerRedundantCheck - * symbolName=sibling */ if (IS_BLACK(LEFT(sibling)) && IS_BLACK(RIGHT(sibling))) { MAKE_RED(sibling); @@ -2192,8 +2188,6 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) { INSIST(sibling != NULL); - /* cppcheck-suppress nullPointerRedundantCheck - * symbolName=sibling */ if (IS_BLACK(LEFT(sibling)) && IS_BLACK(RIGHT(sibling))) { MAKE_RED(sibling); @@ -2328,7 +2322,6 @@ check_properties_helper(dns_rbtnode_t *node) { } } - /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if ((DOWN(node) != NULL) && (!IS_ROOT(DOWN(node)))) { return (false); } @@ -2366,17 +2359,14 @@ check_black_distance_helper(dns_rbtnode_t *node, size_t *distance) { return (true); } - /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if (!check_black_distance_helper(LEFT(node), &dl)) { return (false); } - /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if (!check_black_distance_helper(RIGHT(node), &dr)) { return (false); } - /* cppcheck-suppress nullPointerRedundantCheck symbolName=node */ if (!check_black_distance_helper(DOWN(node), &dd)) { return (false); } @@ -2474,10 +2464,6 @@ print_text_helper(dns_rbtnode_t *root, dns_rbtnode_t *parent, int depth, if (root != NULL) { printnodename(root, true, f); - /* - * Don't use IS_RED(root) as it tests for 'root != NULL' - * and cppcheck produces false positives. - */ fprintf(f, " (%s, %s", direction, COLOR(root) == RED ? "RED" : "BLACK"); @@ -2503,19 +2489,12 @@ print_text_helper(dns_rbtnode_t *root, dns_rbtnode_t *parent, int depth, depth++; - /* - * Don't use IS_RED(root) as it tests for 'root != NULL' - * and cppcheck produces false positives. - */ if (COLOR(root) == RED && IS_RED(LEFT(root))) { fprintf(f, "** Red/Red color violation on left\n"); } print_text_helper(LEFT(root), root, depth, "left", data_printer, f); - /* - * Don't use IS_RED(root) as cppcheck produces false positives. - */ if (COLOR(root) == RED && IS_RED(RIGHT(root))) { fprintf(f, "** Red/Red color violation on right\n"); } diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index b837c55920..cba10249af 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -19,18 +19,6 @@ #include #include -/* - * Redefine CHECK here so cppcheck "sees" the define. - */ -#ifndef CHECK -#define CHECK(op) \ - do { \ - result = (op); \ - if (result != ISC_R_SUCCESS) \ - goto cleanup; \ - } while (0) -#endif /* ifndef CHECK */ - #define RRTYPE_WKS_ATTRIBUTES (0) static isc_mutex_t wks_lock; diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 7f7d4b7d7c..0e840c693c 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -1585,8 +1585,6 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { * XXX Can TCP transfers be forwarded? How would that * work? */ - /* cppcheck-suppress uninitStructMember - * symbolName=tsig.originalid */ id = htons(tsig.originalid); memmove(&header[0], &id, 2); } diff --git a/lib/isc/include/isc/refcount.h b/lib/isc/include/isc/refcount.h index 043ee4d0a4..66df3c9f18 100644 --- a/lib/isc/include/isc/refcount.h +++ b/lib/isc/include/isc/refcount.h @@ -76,7 +76,6 @@ isc_refcount_increment0(isc_refcount_t *target) { #else /* _MSC_VER */ #define isc_refcount_increment0(target) \ ({ \ - /* cppcheck-suppress shadowVariable */ \ uint_fast32_t __v; \ __v = atomic_fetch_add_relaxed(target, 1); \ INSIST(__v < UINT32_MAX); \ @@ -100,7 +99,6 @@ isc_refcount_increment(isc_refcount_t *target) { #else /* _MSC_VER */ #define isc_refcount_increment(target) \ ({ \ - /* cppcheck-suppress shadowVariable */ \ uint_fast32_t __v; \ __v = atomic_fetch_add_relaxed(target, 1); \ INSIST(__v > 0 && __v < UINT32_MAX); \ @@ -124,7 +122,6 @@ isc_refcount_decrement(isc_refcount_t *target) { #else /* _MSC_VER */ #define isc_refcount_decrement(target) \ ({ \ - /* cppcheck-suppress shadowVariable */ \ uint_fast32_t __v; \ __v = atomic_fetch_sub_acq_rel(target, 1); \ INSIST(__v > 0); \ diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 65ac46c4f1..ab8115658c 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -266,9 +266,7 @@ mock_assert(const int result, const char *const expression, (((a) == (b)) ? (void)0 : (_assert_int_equal(a, b, f, l), abort())) #define _assert_int_not_equal(a, b, f, l) \ (((a) != (b)) ? (void)0 : (_assert_int_not_equal(a, b, f, l), abort())) -#else /* UNIT_TESTING */ - -#ifndef CPPCHECK +#else /* UNIT_TESTING */ /* * Assertions @@ -284,27 +282,6 @@ mock_assert(const int result, const char *const expression, /*% Invariant Assertion */ #define INVARIANT(e) ISC_INVARIANT(e) -#else /* CPPCHECK */ - -/*% Require Assertion */ -#define REQUIRE(e) \ - if (!(e)) \ - abort() -/*% Ensure Assertion */ -#define ENSURE(e) \ - if (!(e)) \ - abort() -/*% Insist Assertion */ -#define INSIST(e) \ - if (!(e)) \ - abort() -/*% Invariant Assertion */ -#define INVARIANT(e) \ - if (!(e)) \ - abort() - -#endif /* CPPCHECK */ - #endif /* UNIT_TESTING */ /* @@ -326,14 +303,8 @@ mock_assert(const int result, const char *const expression, #else /* UNIT_TESTING */ -#ifndef CPPCHECK /*% Runtime Check */ #define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond) -#else /* ifndef CPPCHECK */ -#define RUNTIME_CHECK(e) \ - if (!(e)) \ - abort() -#endif /* ifndef CPPCHECK */ #endif /* UNIT_TESTING */ diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index e74fa3b918..3c1cead3a8 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -128,8 +128,6 @@ convert_named_acl(const cfg_obj_t *nameobj, const cfg_obj_t *cctx, for (dacl = ISC_LIST_HEAD(ctx->named_acl_cache); dacl != NULL; dacl = ISC_LIST_NEXT(dacl, nextincache)) { - /* cppcheck-suppress nullPointerRedundantCheck symbolName=dacl - */ if (strcasecmp(aclname, dacl->name) == 0) { if (ISC_MAGIC_VALID(dacl, LOOP_MAGIC)) { cfg_obj_log(nameobj, lctx, ISC_LOG_ERROR, diff --git a/lib/ns/client.c b/lib/ns/client.c index f598387729..5eab55c0e3 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -1444,9 +1444,7 @@ process_ecs(ns_client_t *client, isc_buffer_t *buf, size_t optlen) { if ((addrlen % 8) != 0) { uint8_t bits = ~0U << (8 - (addrlen % 8)); - /* cppcheck-suppress objectIndex */ bits &= paddr[addrbytes - 1]; - /* cppcheck-suppress objectIndex */ if (bits != paddr[addrbytes - 1]) { return (DNS_R_OPTERR); } diff --git a/util/suppressions.txt b/util/suppressions.txt deleted file mode 100644 index 27aa9b6e3a..0000000000 --- a/util/suppressions.txt +++ /dev/null @@ -1,4 +0,0 @@ -unmatchedSuppression:* -preprocessorErrorDirective:* -unknownMacro:* -nullPointerRedundantCheck:*