From: Viktor Szakats Date: Sun, 22 Sep 2024 23:22:36 +0000 (+0200) Subject: build: fix possible `-Wformat-overflow` in lib557 with test bundle builds X-Git-Tag: curl-8_11_0~353 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4619b4103b7c60e5b72acf81b7b38dd2eedc5350;p=thirdparty%2Fcurl.git build: fix possible `-Wformat-overflow` in lib557 with test bundle builds - 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 --- diff --git a/CMake/PickyWarnings.cmake b/CMake/PickyWarnings.cmake index a711efaea7..57b176c3fe 100644 --- a/CMake/PickyWarnings.cmake +++ b/CMake/PickyWarnings.cmake @@ -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 diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4 index 68ff47c602..180b23417a 100644 --- a/m4/curl-compilers.m4 +++ b/m4/curl-compilers.m4 @@ -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 diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 82b7f7f5a9..d715fc575c 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -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) diff --git a/tests/unit/unit1652.c b/tests/unit/unit1652.c index 0052d0d680..a67e4c163d 100644 --- a/tests/unit/unit1652.c +++ b/tests/unit/unit1652.c @@ -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 /*