]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: fix possible `-Wformat-overflow` in lib557 with test bundle builds
authorViktor Szakats <commit@vsz.me>
Sun, 22 Sep 2024 23:22:36 +0000 (01:22 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 23 Sep 2024 09:52:55 +0000 (11:52 +0200)
- lib557: suppress `-Wformat-overflow` warning in source.
  Fixes:
  ```
  lib557.c: In function ‘test_float_formatting’:
  lib557.c:1408:37: error: ‘%*f’ directive output of 2147483648 bytes exceeds ‘INT_MAX’ [-Werror=format-overflow=]
   1408 |   curl_msnprintf(buf, sizeof(buf), "%*f", INT_MIN, 9.1);
        |                                     ^~~
  lib557.c:1408:3: note: ‘curl_msnprintf’ output 2147483649 bytes
   1408 |   curl_msnprintf(buf, sizeof(buf), "%*f", INT_MIN, 9.1);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ```
  Ref: https://app.circleci.com/pipelines/github/curl/curl/10226/workflows/87642ee9-cda6-4916-8206-c82aac5f595e/jobs/107669?invite=true#step-106-40996_46

  The root cause of why this option gets enabled remains undiscovered.

Reported-by: Daniel Stenberg
  Fixes #15008
  Follow-up to 71cf0d1fca9e1f53524e1545ef0c08d174458d80 #14772

- build: drop `-Wno-format-overflow` from picky warning list.
  These options only get used with picky warnings enabled.
  Follow-up to 145f87b9e89f3a5e287233fe7d3cf57aca23dd8c #14598

- unit1652: suppress in source (and not rely on picky warnings anymore.)

Closes #15012

CMake/PickyWarnings.cmake
m4/curl-compilers.m4
tests/libtest/lib557.c
tests/unit/unit1652.c

index a711efaea76997a2a5d0c5ba748f64be356e16b3..57b176c3fed41c765f27e09a1e6ebd56e5a03ef8 100644 (file)
@@ -206,7 +206,6 @@ if(PICKY_COMPILER)
         list(APPEND WPICKY_ENABLE
           -Walloc-zero                     #             gcc  7.0
           -Wduplicated-branches            #             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 68ff47c6022e16ab85acb5fd007229cf95c3d811..180b23417a12a66be59fd1877b638050cd563e41 100644 (file)
@@ -1076,7 +1076,6 @@ 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 -Wno-format-overflow"
             tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2"
             tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough"
           fi
index 82b7f7f5a90e0c98858626e12ece83fde6974bc8..d715fc575c7399446c8fddfacb1afe92bfd669e5 100644 (file)
@@ -41,6 +41,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat"
 #pragma GCC diagnostic ignored "-Wformat-extra-args"
+#if !defined(__clang__) && __GNUC__ >= 7
+#pragma GCC diagnostic ignored "-Wformat-overflow"
+#endif
 #endif
 
 #if (SIZEOF_CURL_OFF_T > SIZEOF_LONG)
index 0052d0d68022d843ad7c735fc01626f63f6faf4e..a67e4c163d63d837ca6cd46b158e45192d59c470 100644 (file)
@@ -30,6 +30,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat"
 #pragma GCC diagnostic ignored "-Wformat-zero-length"
+#if !defined(__clang__) && __GNUC__ >= 7
+#pragma GCC diagnostic ignored "-Wformat-overflow"
+#endif
 #endif
 
 /*