From: Marco Bettini Date: Thu, 24 Mar 2022 09:45:37 +0000 (+0000) Subject: lib: str_begins*() - Suppress static code analyzer false positives X-Git-Tag: 2.4.0~4216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba6ecc0957e3bb98c8a0be1874ec9e43b3760969;p=thirdparty%2Fdovecot%2Fcore.git lib: str_begins*() - Suppress static code analyzer false positives The code analyzer is not able to properly infer that str_begins_builtin_success() cannot be invoked when the previous strncmp() does not match. It then complies about overrun pointers arithmetic that is just not possible to happen. --- diff --git a/src/lib/strfuncs.h b/src/lib/strfuncs.h index 32450dffaf..de13361e73 100644 --- a/src/lib/strfuncs.h +++ b/src/lib/strfuncs.h @@ -102,7 +102,7 @@ str_begins_icase_with(const char *haystack, const char *needle) { return needle[str_match_icase(haystack, needle)] == '\0'; } -#if defined(__GNUC__) && (__GNUC__ >= 2) +#if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(STATIC_CHECKER) /* GCC (and Clang) are known to have a compile-time strlen("literal") shortcut, and an optimised strncmp(), so use that by default. Macro is multi-evaluation safe. */ static inline bool