curl/m4
Viktor Szakats 3829759bd0
build: enable missing OpenSSF-recommended warnings, with fixes
https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
as of 2023-11-29 [1].

Enable new recommended warnings (except `-Wsign-conversion`):

- enable `-Wformat=2` for clang (in both cmake and autotools).
- add `CURL_PRINTF()` internal attribute and mark functions accepting
  printf arguments with it. This is a copy of existing
  `CURL_TEMP_PRINTF()` but using `__printf__` to make it compatible
  with redefinting the `printf` symbol:
  https://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_5.html#SEC94
- fix `CURL_PRINTF()` and existing `CURL_TEMP_PRINTF()` for
  mingw-w64 and enable it on this platform.
- enable `-Wimplicit-fallthrough`.
- enable `-Wtrampolines`.
- add `-Wsign-conversion` commented with a FIXME.
- cmake: enable `-pedantic-errors` the way we do it with autotools.
  Follow-up to d5c0351055 #2747
- lib/curl_trc.h: use `CURL_FORMAT()`, this also fixes it to enable format
  checks. Previously it was always disabled due to the internal `printf`
  macro.

Fix them:

- fix bug where an `set_ipv6_v6only()` call was missed in builds with
  `--disable-verbose` / `CURL_DISABLE_VERBOSE_STRINGS=ON`.
- add internal `FALLTHROUGH()` macro.
- replace obsolete fall-through comments with `FALLTHROUGH()`.
- fix fallthrough markups: Delete redundant ones (showing up as
  warnings in most cases). Add missing ones. Fix indentation.
- silence `-Wformat-nonliteral` warnings with llvm/clang.
- fix one `-Wformat-nonliteral` warning.
- fix new `-Wformat` and `-Wformat-security` warnings.
- fix `CURL_FORMAT_SOCKET_T` value for mingw-w64. Also move its
  definition to `lib/curl_setup.h` allowing use in `tests/server`.
- lib: fix two wrongly passed string arguments in log outputs.
  Co-authored-by: Jay Satiro
- fix new `-Wformat` warnings on mingw-w64.

[1] 56c0fde389/docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C%2B%2B.md

Closes #12489
2023-12-16 13:12:37 +00:00
..
.gitignore copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-amissl.m4 tidy-up: use OPENSSL_VERSION_NUMBER 2023-11-08 17:55:22 +00:00
curl-bearssl.m4 tidy-up: mostly whitespace nits 2023-08-31 23:02:10 +00:00
curl-compilers.m4 build: enable missing OpenSSF-recommended warnings, with fixes 2023-12-16 13:12:37 +00:00
curl-confopts.m4 misc: fix spelling mistakes 2023-05-23 10:42:09 +02:00
curl-functions.m4 tidy-up: whitespace 2023-12-08 03:28:50 +00:00
curl-gnutls.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-mbedtls.m4 tidy-up: mostly whitespace nits 2023-08-31 23:02:10 +00:00
curl-openssl.m4 tidy-up: use OPENSSL_VERSION_NUMBER 2023-11-08 17:55:22 +00:00
curl-override.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-reentrant.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-rustls.m4 tidy-up: mostly whitespace nits 2023-08-31 23:02:10 +00:00
curl-schannel.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-sectransp.m4 cmake, configure: also link with CoreServices 2023-09-20 08:38:19 +02:00
curl-sysconfig.m4 cmake, configure: also link with CoreServices 2023-09-20 08:38:19 +02:00
curl-wolfssl.m4 tidy-up: mostly whitespace nits 2023-08-31 23:02:10 +00:00
xc-am-iface.m4 build: drop the use of XC_AMEND_DISTCLEAN 2023-03-03 09:54:44 +01:00
xc-cc-check.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
xc-lt-iface.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
xc-translit.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
xc-val-flgs.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
zz40-xc-ovr.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
zz50-xc-ovr.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
zz60-xc-ovr.m4 copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00