]> git.ipfire.org Git - thirdparty/curl.git/commit
printf: fix mingw-w64 format checks
authorViktor Szakats <commit@vsz.me>
Thu, 22 Aug 2024 08:54:42 +0000 (10:54 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 2 Sep 2024 19:03:01 +0000 (21:03 +0200)
commite512fbfa6752705b2f941c79c2b8e2dfbe93d28a
tree1a2f1d07051c7e692d232910d9262367934d0e33
parent6004f96734a30c84e9061611ef04b8a79820a463
printf: fix mingw-w64 format checks

Change mingw-w64 printf format checks in public curl headers to use
`__MINGW_PRINTF_FORMAT` instead of `gnu_printf`. This syncs the format
checker with format string macros published via `curl/system.h`. (Also
disable format checks for mingw-w64 older than 3.0.0 (2013-09-20) and
classic-mingw, which do not support this macro.)

This fixes bogus format checker `-Wformat` warnings in 3rd party code
using curl format strings with the curl printf functions, when using
mingw-w64 7.0.0 (2019-11-10) and older (with GCC, MSVCRT).

It also allows to delete two workaounds for this within curl itself:
- setting `-D__USE_MINGW_ANSI_STDIO=1` for mingw-w64 via cmake and
  configure for `docs/examples` and `tests/http/clients`.
  Ref: c730c8549b5b67e7668ca5d2cd82c3cc183e125d #14640

The format check macro is incompatible (depending on mingw-w64 version
and configuration) with the C99 `%z` (`size_t`) format string used
internally by curl.

To work around this problem, override the format check style in curl
public headers to use `gnu_printf`. This is compatible with `%z` in all
mingw-w64 versions and allows keeping the C99 format strings internally.

Also:
- lib/ws.c: add missing space to an error message.
- docs/examples/ftpgetinfo.c: fix to use standard printf.

Ref: #14643 (take 1)
Follow-up to 3829759bd042c03225ae862062560f568ba1a231 #12489

Closes #14703
12 files changed:
configure.ac
docs/examples/CMakeLists.txt
docs/examples/Makefile.am
docs/examples/ftpgetinfo.c
include/curl/curl.h
include/curl/mprintf.h
lib/curl_printf.h
lib/curl_setup.h
lib/mprintf.c
lib/ws.c
tests/http/clients/CMakeLists.txt
tests/http/clients/Makefile.am