]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: str_begins*() - Suppress static code analyzer false positives
authorMarco Bettini <marco.bettini@open-xchange.com>
Thu, 24 Mar 2022 09:45:37 +0000 (09:45 +0000)
committerMarco Bettini <marco.bettini@open-xchange.com>
Thu, 24 Mar 2022 09:51:28 +0000 (09:51 +0000)
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.

src/lib/strfuncs.h

index 32450dffaf40dd00f4fdb4cdaba925b0d2df1654..de13361e731805118c41706add4be67f9370d3e2 100644 (file)
@@ -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