Skip to content

build: drop global suppression of -Wformat-nonliteral, fix fallouts - #20366

Closed
vszakats wants to merge 12 commits into
curl:masterfrom
vszakats:bfmtlit
Closed

build: drop global suppression of -Wformat-nonliteral, fix fallouts#20366
vszakats wants to merge 12 commits into
curl:masterfrom
vszakats:bfmtlit

Conversation

@vszakats

@vszakats vszakats commented Jan 20, 2026

Copy link
Copy Markdown
Member

Extend two existing local suppressions to GCC, and add another
GCC-specific one as a replacement.

Before this patch suppressing this warning was odd with clang, because
after this option, -Wformat=2 is used, which re-enables it.

Also:

  • mprintf: minimize scope of a warning suppression.
  • tests/server: suppress this warning for a system vsnprintf() call
    where it could trigger in C89 builds or with
    CFLAGS=-DCURL_NO_FMT_CHECKS set. Seen with Apple clang 17:
    curl/tests/server/util.c:114:37: warning: format string is not a string literal [-Wformat-nonliteral]
      114 |   vsnprintf(buffer, sizeof(buffer), msg, ap);
          |                                     ^~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:124:69: note: expanded from macro 'vsnprintf'
      124 | #define vsnprintf(str, len, ...) __vsnprintf_chk_func (str, len, 0, __VA_ARGS__)
          |                                                                     ^~~~~~~~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:81:65: note: expanded from macro '__vsnprintf_chk_func'
       81 |         __builtin___vsnprintf_chk (str, len, flag, __darwin_obsz(str), format, ap)
          |                                                                        ^~~~~~
    

Ref: #20363

@github-actions github-actions Bot added the tests label Jan 20, 2026
@vszakats vszakats changed the title build: drop global suppression of -Wformat-nonliteral build: drop global suppression of -Wformat-nonliteral, fix fallouts Jan 20, 2026
@vszakats vszakats closed this in f07a98a Jan 20, 2026
@vszakats
vszakats deleted the bfmtlit branch January 20, 2026 11:39
vszakats added a commit that referenced this pull request Mar 12, 2026
- tool_getparam: revert an unnecessary/no-op C89 warning silencer.
  Follow-up to 09c9afd #20363

- tool_writeout: add comment saying silencing is a no-op for llvm/clang.
  For `strftime()` it is a GCC-specific, as of llvm/clang v22.1.0.
  Follow-up to f07a98a #20366

- unit1652: drop always-false `!defined(__clang__)` guard.
  Pointed-out-by: Orgad Shaneh
  Ref: #20902
  Follow-up to 7e814c8 #16062

- unit1652: document that `-Wformat` is necessary for GCC v5 to v8.
  Follow-up to 71cf0d1 #14772

Closes #20908
vszakats added a commit that referenced this pull request Mar 18, 2026
…warnings

Extend `#pragma diagnostic push`/`pop` guards to the whole codebase
(from tests and examples only) to disable it for GCC <4.6. Rename guard
to `CURL_HAVE_DIAG` and make it include llvm/clang to be interchangeable
with `__GNUC__ || __clang__` in this context.

The above means no longer disabling certain warnings locally, so pair
this with disabling all picky warnings for GCC <4.6.

Also:
- drop global workarounds for misbehaving GCC <4.6 compiler warnings.
  Not needed with picky warnings disabled.

Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98a #20366
Fixes #20892
Fixes #20924
Closes #20902
Closes #20907
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
- tool_getparam: revert an unnecessary/no-op C89 warning silencer.
  Follow-up to 09c9afd curl#20363

- tool_writeout: add comment saying silencing is a no-op for llvm/clang.
  For `strftime()` it is a GCC-specific, as of llvm/clang v22.1.0.
  Follow-up to f07a98a curl#20366

- unit1652: drop always-false `!defined(__clang__)` guard.
  Pointed-out-by: Orgad Shaneh
  Ref: curl#20902
  Follow-up to 7e814c8 curl#16062

- unit1652: document that `-Wformat` is necessary for GCC v5 to v8.
  Follow-up to 71cf0d1 curl#14772

Closes curl#20908
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
…warnings

Extend `#pragma diagnostic push`/`pop` guards to the whole codebase
(from tests and examples only) to disable it for GCC <4.6. Rename guard
to `CURL_HAVE_DIAG` and make it include llvm/clang to be interchangeable
with `__GNUC__ || __clang__` in this context.

The above means no longer disabling certain warnings locally, so pair
this with disabling all picky warnings for GCC <4.6.

Also:
- drop global workarounds for misbehaving GCC <4.6 compiler warnings.
  Not needed with picky warnings disabled.

Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98a curl#20366
Fixes curl#20892
Fixes curl#20924
Closes curl#20902
Closes curl#20907
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