From: Viktor Szakats Date: Tue, 9 Dec 2025 19:06:33 +0000 (+0100) Subject: build: set `-Wno-format-signedness` X-Git-Tag: rc-8_18_0-2~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd19433b0ebbd719487577f8ffa25ba6bdb8f909;p=thirdparty%2Fcurl.git build: set `-Wno-format-signedness` Explicitly disable these warnings to allow using `-Weverything`. There are around 600 of them across the codebase. Silencing them has some drawbacks: - enums (`CURLcode` mostly) would have to be cast to int to avoid different signedness depending on C compiler. (llvm/gcc: unsigned, MSVC/clang-cl: signed by default) - hex masks need casts to unsigned to avoid the warning. - fixing remaining warnings is annoying without fixing the above. - without fixing all warnings the option cannot be enabled, to keep the codebase warning free. Ref: #18343 (silenced all warnings, but without the enum cast) Follow-up to 92f215fea1aa8bd5b1709d38f42aab77ab3fc662 #18477 Closes #19907 --- diff --git a/CMake/PickyWarnings.cmake b/CMake/PickyWarnings.cmake index e9a0d61c0e..00451f7480 100644 --- a/CMake/PickyWarnings.cmake +++ b/CMake/PickyWarnings.cmake @@ -232,6 +232,12 @@ if(PICKY_COMPILER) -Wcast-function-type-strict # clang 16.0 appleclang 16.0 ) endif() + if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.1) OR + (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0)) + list(APPEND _picky_enable + -Wno-format-signedness # clang 19.1 gcc 5.1 appleclang 17.0 # In clang-cl enums are signed ints by default + ) + endif() if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 21.1) list(APPEND _picky_enable -Warray-compare # clang 20.1 gcc 12.0 appleclang ? @@ -282,6 +288,7 @@ if(PICKY_COMPILER) if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) list(APPEND _picky_enable -Warray-bounds=2 # clang 3.0 gcc 5.0 (clang default: -Warray-bounds) + -Wno-format-signedness # clang 19.1 gcc 5.1 appleclang 17.0 ) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0) diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4 index dda5b7934e..343391d602 100644 --- a/m4/curl-compilers.m4 +++ b/m4/curl-compilers.m4 @@ -936,6 +936,10 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ if test "$compiler_num" -ge "1700"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-function-type-strict]) # with Apple clang it requires 16.0 or above fi + dnl clang 19 or later + if test "$compiler_num" -ge "1901"; then + tmp_CFLAGS="$tmp_CFLAGS -Wno-format-signedness" + fi dnl clang 20 or later if test "$compiler_num" -ge "2001"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [array-compare]) @@ -1115,6 +1119,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ dnl Only gcc 5 or later if test "$compiler_num" -ge "500"; then tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2" + tmp_CFLAGS="$tmp_CFLAGS -Wno-format-signedness" fi # dnl Only gcc 6 or later