Merge branch '2886-drop-cppcheck' into 'main'

Drop cppcheck

Closes #2886 and #2698

See merge request isc-projects/bind9!5574
This commit is contained in:
Michal Nowak 2021-12-14 14:07:57 +00:00
commit 11ab4ffb42
13 changed files with 6 additions and 116 deletions

View file

@ -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")))
)

2
.gitignore vendored
View file

@ -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

View file

@ -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.

View file

@ -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]

View file

@ -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);

View file

@ -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");
}

View file

@ -19,18 +19,6 @@
#include <isc/netdb.h>
#include <isc/once.h>
/*
* 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;

View file

@ -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);
}

View file

@ -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); \

View file

@ -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 */

View file

@ -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,

View file

@ -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);
}

View file

@ -1,4 +0,0 @@
unmatchedSuppression:*
preprocessorErrorDirective:*
unknownMacro:*
nullPointerRedundantCheck:*