cppcheck is not aware that the bin/dnssec/dnssectool.c:fatal() function
does not return. This triggers certain cppcheck 2.2 false positives,
for example:
bin/dnssec/dnssec-signzone.c:3471:13: warning: Either the condition 'ndskeys==8' is redundant or the array 'dskeyfile[8]' is accessed at index 8, which is out of bounds. [arrayIndexOutOfBoundsCond]
dskeyfile[ndskeys++] = isc_commandline_argument;
^
bin/dnssec/dnssec-signzone.c:3468:16: note: Assuming that condition 'ndskeys==8' is not redundant
if (ndskeys == MAXDSKEYS) {
^
bin/dnssec/dnssec-signzone.c:3471:13: note: Array index out of bounds
dskeyfile[ndskeys++] = isc_commandline_argument;
^
bin/dnssec/dnssec-signzone.c:772:20: warning: Either the condition 'l->hashbuf==NULL' is redundant or there is pointer arithmetic with NULL pointer. [nullPointerArithmeticRedundantCheck]
memset(l->hashbuf + l->entries * l->length, 0, l->length);
^
bin/dnssec/dnssec-signzone.c:768:18: note: Assuming that condition 'l->hashbuf==NULL' is not redundant
if (l->hashbuf == NULL) {
^
bin/dnssec/dnssec-signzone.c:772:20: note: Null pointer addition
memset(l->hashbuf + l->entries * l->length, 0, l->length);
^
Instead of suppressing all such warnings individually, conditionally
define a preprocessor macro which prevents them from being triggered.
setup_logging(mctx, &log);
if (predecessor == NULL) {
- /* cppcheck-suppress nullPointerRedundantCheck */
if (label == NULL) {
fatal("the key label was not specified");
}
isc_result_totext(ret));
}
- /* cppcheck-suppress nullPointerRedundantCheck */
if (strchr(label, ':') == NULL) {
char *l;
int len;
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) {
}
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) {
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);