From 3efc53f5e9e69696aff40041dfe563160b73e938 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 26 Feb 2025 01:33:49 +0100 Subject: [PATCH] build: silence mingw32ce C99 format warnings, simplify CI `./configure` mingw32ce builds enable C99 mode automatically, that triggers compiler warnings in gcc 4.4.0. We initially worked it around in CI by suppressing the detection of C99 with `ac_cv_prog_cc_c99=no`. Replace it with automatically silencing the bogus warnings in C99 mode, for all build systems: ``` lib/ftp.c: In function 'Curl_GetFTPResponse': lib/ftp.c:726: error: format '%zd' expects type 'signed size_t', but argument 4 has type 'ssize_t' lib/ws.c: In function 'ws_dec_pass_payload': lib/ws.c:304: error: format '%zd' expects type 'signed size_t', but argument 3 has type 'ssize_t' lib/ws.c: In function 'ws_enc_write_head': lib/ws.c:581: error: format '%zd' expects type 'signed size_t', but argument 3 has type 'long int' lib/vtls/schannel.c: In function 'schannel_connect_step1': lib/vtls/schannel.c:1122: error: format '%zd' expects type 'signed size_t', but argument 3 has type 'ssize_t' lib/vtls/schannel.c: In function 'schannel_connect_step2': lib/vtls/schannel.c:1311: error: format '%zd' expects type 'signed size_t', but argument 3 has type 'ssize_t' lib/vtls/schannel.c: In function 'schannel_send': lib/vtls/schannel.c:1793: error: format '%zd' expects type 'signed size_t', but argument 3 has type 'ssize_t' lib/vtls/schannel.c:1810: error: format '%zd' expects type 'signed size_t', but argument 3 has type 'ssize_t' lib/vtls/schannel.c: In function 'schannel_shutdown': lib/vtls/schannel.c:2286: error: format '%zd' expects type 'signed size_t', but argument 4 has type 'ssize_t' lib/vtls/vtls.c: In function 'ssl_cf_recv': lib/vtls/vtls.c:1422: error: format '%zd' expects type 'signed size_t', but argument 5 has type 'ssize_t' ``` Ref: https://github.com/curl/curl/actions/runs/13533841306/job/37821720902?pr=16492#step:9:20 Also: simplify Windows CE job configuration in GHA/windows. Follow-up to 2a292c39846107228201674d686be5b3ed96674d #15975 Closes #16492 --- .github/workflows/windows.yml | 20 +++++++++----------- lib/curl_setup.h | 8 ++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ba2ad3561a..60f0fb2965 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -623,16 +623,16 @@ jobs: - name: 'configure' run: | - MINGW32CE_ROOT="${HOME}/opt/mingw32ce" + PATH="$HOME/opt/mingw32ce/bin:$PATH" if [ '${{ matrix.build }}' = 'cmake' ]; then cmake -B bld \ -DCMAKE_SYSTEM_NAME=WindowsCE \ -DCMAKE_SYSTEM_VERSION=8.0 \ -DCMAKE_SYSTEM_PROCESSOR=arm \ - -DCMAKE_C_COMPILER_TARGET=arm-wince-mingw32ce \ - -DCMAKE_C_COMPILER="${MINGW32CE_ROOT}/bin/arm-mingw32ce-gcc" \ - -DCMAKE_RC_COMPILER="${MINGW32CE_ROOT}/bin/arm-mingw32ce-windres" \ - -DMINGW32CE_LIBRARY_DIR="${MINGW32CE_ROOT}/arm-mingw32ce/lib" \ + -DCMAKE_C_COMPILER_TARGET=arm-mingw32ce \ + -DCMAKE_C_COMPILER=arm-mingw32ce-gcc \ + -DCMAKE_RC_COMPILER=arm-mingw32ce-windres \ + -DMINGW32CE_LIBRARY_DIR="$HOME/opt/mingw32ce/arm-mingw32ce/lib" \ -DCMAKE_IGNORE_PREFIX_PATH="$(brew --prefix)" \ -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \ -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_STATIC_CURL=OFF \ @@ -642,12 +642,7 @@ jobs: else autoreconf -fi mkdir bld && cd bld && ../configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \ - ac_cv_prog_cc_c99=no \ - CC="${MINGW32CE_ROOT}/bin/arm-mingw32ce-gcc" \ - AR="${MINGW32CE_ROOT}/bin/arm-mingw32ce-ar" \ - RANLIB="${MINGW32CE_ROOT}/bin/arm-mingw32ce-ranlib" \ - RC="${MINGW32CE_ROOT}/bin/arm-mingw32ce-windres" \ - --host=arm-wince-mingw32ce \ + --host=arm-mingw32ce \ --with-schannel \ --without-libpsl \ --disable-shared @@ -664,6 +659,7 @@ jobs: - name: 'build' run: | + PATH="$HOME/opt/mingw32ce/bin:$PATH" if [ '${{ matrix.build }}' = 'cmake' ]; then cmake --build bld else @@ -677,6 +673,7 @@ jobs: - name: 'build tests' if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time run: | + PATH="$HOME/opt/mingw32ce/bin:$PATH" if [ '${{ matrix.build }}' = 'cmake' ]; then cmake --build bld --target testdeps else @@ -686,6 +683,7 @@ jobs: - name: 'build examples' if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time run: | + PATH="$HOME/opt/mingw32ce/bin:$PATH" if [ '${{ matrix.build }}' = 'cmake' ]; then cmake --build bld --target curl-examples else diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 92d911dfb9..724aa7f32b 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -120,6 +120,14 @@ # endif #endif +/* Avoid bogus format check warnings with mingw32ce gcc 4.4.0 in + C99 (-std=gnu99) mode */ +#if defined(__MINGW32CE__) && !defined(CURL_NO_FMT_CHECKS) && \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) && \ + (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)) +#define CURL_NO_FMT_CHECKS +#endif + /* Compatibility */ #ifdef ENABLE_IPV6 #define USE_IPV6 1