Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printf: fix mingw-w64 format checks, take 2 #14703

Closed
wants to merge 33 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Aug 27, 2024

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:

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 3829759 #12489


  • give public CURL_TEMP_PRINTF a better name? And/or its internal counterpart.

@vszakats vszakats marked this pull request as draft August 27, 2024 13:01
@vszakats

This comment was marked as resolved.

@vszakats vszakats closed this Aug 27, 2024
@vszakats vszakats deleted the mingw-printf-alt-test branch August 27, 2024 13:42
@vszakats vszakats restored the mingw-printf-alt-test branch September 1, 2024 01:06
@vszakats vszakats reopened this Sep 1, 2024
@vszakats vszakats added build Windows Windows-specific labels Sep 1, 2024
@vszakats vszakats changed the title [TEST] mingw printf alt test [TEST] mingw printf format check alternate fix Sep 1, 2024
@vszakats vszakats marked this pull request as ready for review September 1, 2024 03:43
@vszakats vszakats changed the title [TEST] mingw printf format check alternate fix [TEST] printf: fix mingw-w64 format checks, take 2 Sep 1, 2024
@vszakats vszakats changed the title [TEST] printf: fix mingw-w64 format checks, take 2 printf: fix mingw-w64 format checks, take 2 Sep 1, 2024
@vszakats
Copy link
Member Author

vszakats commented Sep 1, 2024

Made this PR work on the second attempt.

@vszakats vszakats closed this in e512fbf Sep 2, 2024
@vszakats vszakats deleted the mingw-printf-alt-test branch September 2, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant