]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: use -Wno-format-overflow
authorDaniel Stenberg <daniel@haxx.se>
Mon, 19 Aug 2024 12:17:55 +0000 (14:17 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 19 Aug 2024 21:20:45 +0000 (23:20 +0200)
-Wformat-overflow is not a warning that we want enabled as it does not
help us. It can only bring us false positives since it warns on bad uses
of sprintf and vsprintf ("that might overflow the destination buffer").
Two functions we explicitly ban in curl code.

The only way this flag triggers warnings in curl code is false positives
for functions we have marked with the CURL_PRINTF() macro.

Further: it seems -Wformat-trunaction option might in turn also enable
-Wformat-overflow, so if this second option is used, we need to
explicitly set -Wno-format-overflow - not just skip setting
-Wformat-overflow.

Reported-by: Viktor Szakats
Fixes #14168
Closes #14598

CMake/PickyWarnings.cmake
m4/curl-compilers.m4

index 400e0be77adcd86b484422f9b782c305b62509ae..a711efaea76997a2a5d0c5ba748f64be356e16b3 100644 (file)
@@ -206,7 +206,7 @@ if(PICKY_COMPILER)
         list(APPEND WPICKY_ENABLE
           -Walloc-zero                     #             gcc  7.0
           -Wduplicated-branches            #             gcc  7.0
-          -Wformat-overflow=2              #             gcc  7.0
+          -Wno-format-overflow             #             gcc  7.0
           -Wformat-truncation=2            #             gcc  7.0
           -Wimplicit-fallthrough           # clang  4.0  gcc  7.0
           -Wrestrict                       #             gcc  7.0
index 27b84f861a6ffd8187f06f0ee4069530bb157df6..0fde2f9455dae35dcefa01f5e547e8dc1e7548a4 100644 (file)
@@ -1068,7 +1068,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
             CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
             CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
             CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
-            tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
+            tmp_CFLAGS="$tmp_CFLAGS -Wno-format-overflow"
             tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2"
             tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough"
           fi