diff --git a/.cppcheck.suppressions b/.cppcheck.suppressions index 529324b48..154eebed2 100644 --- a/.cppcheck.suppressions +++ b/.cppcheck.suppressions @@ -3,3 +3,8 @@ // because all the places we do this are valid and won't cause problems even // on a ILP64 platform because we're careful about using NULL rather than 0. varFuncNullUB +// Suppress the warning about unmatched suppressions. At the moment these +// warnings are emitted even when removing the suppression comment results in +// the warning being suppressed. In other words this unmatchedSuppression +// warnings are false positives. +unmatchedSuppression diff --git a/build_tools/lint.fish b/build_tools/lint.fish index 6d69ff566..0b14e564a 100755 --- a/build_tools/lint.fish +++ b/build_tools/lint.fish @@ -114,7 +114,9 @@ if set -q c_files[1] echo echo ======================================== - echo "Running `cppcheck --check-config` to identify missing includes similar problems" + echo 'Running `cppcheck --check-config` to identify missing includes similar problems.' + echo 'Ignore unmatchedSuppression warnings as they are probably false positives we' + echo 'cannot suppress.' echo ======================================== cppcheck $cppcheck_args --check-config $c_files 2>&1 end diff --git a/src/autoload.cpp b/src/autoload.cpp index a10de1364..dbfa54e9f 100644 --- a/src/autoload.cpp +++ b/src/autoload.cpp @@ -1,7 +1,6 @@ // The classes responsible for autoloading functions and completions. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/builtin.cpp b/src/builtin.cpp index 43b1b049d..2d099db15 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/src/builtin_printf.cpp b/src/builtin_printf.cpp index 645dd982b..d690dcc4d 100644 --- a/src/builtin_printf.cpp +++ b/src/builtin_printf.cpp @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index a210cbb75..71592d971 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -3,7 +3,9 @@ #include #include +#include #include +#include #include #include #include diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index b19ad38e8..afa11ee4d 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -720,8 +720,8 @@ bool regex_replacer_t::replace_matches(const wchar_t *arg) { done = true; } else { bufsize = outlen; - // cppcheck-suppress memleakOnRealloc - output = (wchar_t *)realloc(output, sizeof(wchar_t) * bufsize); + wchar_t *new_output = (wchar_t *)realloc(output, sizeof(wchar_t) * bufsize); + if (new_output) output = new_output; } } diff --git a/src/env.cpp b/src/env.cpp index 0fcee01c5..d95e7e0cc 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -8,9 +8,7 @@ #include #include #include -#ifdef HAVE__NL_MSG_CAT_CNTR #include -#endif #include #include #include diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index d0fcdab3c..c19222e63 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #ifdef HAVE_SYS_SELECT_H #include diff --git a/src/exec.cpp b/src/exec.cpp index bd6ae4560..b98a1d23f 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/src/fish.cpp b/src/fish.cpp index cc84686c0..6f9dd50f5 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "config.h" -#include #include #include #include @@ -47,13 +46,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "function.h" #include "history.h" #include "input.h" -#include "input_common.h" #include "io.h" #include "parser.h" #include "path.h" #include "proc.h" #include "reader.h" -#include "wildcard.h" #include "wutil.h" // IWYU pragma: keep // PATH_MAX may not exist. diff --git a/src/history.cpp b/src/history.cpp index 0f07f566f..9b2d0dd85 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1450,7 +1450,11 @@ static bool format_history_record(const history_item_t &item, const wchar_t *sho streams.out.append(timestamp_string); } streams.out.append(item.str()); - streams.out.append(null_terminate ? L'\0' : L'\n'); + if (null_terminate) { + streams.out.append(L'\0'); + } else { + streams.out.append(L'\n'); + } return true; } diff --git a/src/history.h b/src/history.h index a8aa51575..c6f55a679 100644 --- a/src/history.h +++ b/src/history.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/src/pager.cpp b/src/pager.cpp index 4a952c205..3c4adc7dd 100644 --- a/src/pager.cpp +++ b/src/pager.cpp @@ -3,7 +3,6 @@ // IWYU pragma: no_include #include #include -#include #include #include #include diff --git a/src/parser.cpp b/src/parser.cpp index 914fcf036..fa9bbe1d4 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/src/screen.cpp b/src/screen.cpp index 54a1203f3..4fc38d691 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -31,7 +31,6 @@ #include #include "common.h" -#include "env.h" #include "fallback.h" // IWYU pragma: keep #include "highlight.h" #include "output.h" diff --git a/src/signal.cpp b/src/signal.cpp index a718d250e..46e501b81 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -14,7 +14,6 @@ #include "fallback.h" // IWYU pragma: keep #include "proc.h" #include "reader.h" -#include "signal.h" #include "wutil.h" // IWYU pragma: keep /// Struct describing an entry for the lookup table used to convert between signal names and signal diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 29d11639c..672c26693 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/src/wutil.cpp b/src/wutil.cpp index 25556c92f..48a37590c 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/src/wutil.h b/src/wutil.h index 601fac936..6037ef06d 100644 --- a/src/wutil.h +++ b/src/wutil.h @@ -3,6 +3,7 @@ #define FISH_WUTIL_H #include +#include #include #include #include