{"author":"Viktor Szakats","author_email":"commit@vsz.me","author_time":1756979793,"commit_time":1758356175,"committer":"Viktor Szakats","committer_email":"commit@vsz.me","hash":"92f215fea1aa8bd5b1709d38f42aab77ab3fc662","message":"build: address some `-Weverything` warnings, update picky warnings\n\n`-Weverything` is not enabled by curl, and not recommended by LLVM,\nbecause it may enable experimental options, and will result in new\nfallouts after toolchain upgrades. This patch aims to fix/silence as much\nas possible as found with llvm/clang 21.1.0. It also permanently enables\nwarnings that were fixed in source and deemed manageable in the future.\n`-Wformat` warnings are addressed separately via #18343.\n\nFix/silence warnings in the source:\n- typecheck-gcc.h: fix `-Wreserved-identifier`.\n- lib: silence `-Wcast-function-type-strict`.\n  For llvm 16+ or Apple clang 16+.\n- asyn-ares: limit `HAPPY_EYEBALLS_DNS_TIMEOUT` to old c-ares versions.\n- curl_trc: fix `-Wc++-hidden-decl`.\n- doh: fix `-Wc++-keyword`.\n- ftp: fix `-Wreserved-identifier`.\n- ldap: fix `-Wreserved-identifier`.\n- mqtt: comment unused macro to avoid warning.\n- multi_ev: drop unused macros to avoid warnings.\n- setopt: fix useless `break;` after `return;`.\n- gtls, mbedtls, rustls: silence `-Wconditional-uninitialized`.\n- socks_sspi, schannel, x509asn1: fix `-Wimplicit-int-enum-cast`.\n- x509asn1: fix `-Wc++-keyword`.\n- openssl: scope `OSSL_UI_METHOD_CAST` to avoid unused macro warning.\n- libssh2, wolfssl: drop unused macros.\n- curl_ngtcp2, curl_quiche, httpsrr, urlapi: drop/limit unused macros.\n- tool_getparam: fix useless `break;` after `return;` or `break;`.\n  Not normally enabled because it doesn't work with unity.\n  https://github.com/llvm/llvm-project/issues/71046\n- tool_operate: fix `-Wc++-keyword`.\n- curlinfo: fix a `-Wunsafe-buffer-usage`.\n- tests: silence `-Wformat-non-iso`.\n- lib557: fix `-Wreserved-identifier`.\n- lib1565: silence `-Wconditional-uninitialized`.\n\nEnable the above clang warnings permanently in picky mode:\n- `-Wc++-hidden-decl`\n- `-Wc++-keyword` (except for Windows, where it collides with `wchar_t`)\n- `-Wcast-function-type-strict`\n- `-Wcast-function-type`\n- `-Wconditional-uninitialized`\n- `-Wformat-non-iso` (except for clang-cl)\n- `-Wreserved-identifier`\n- `-Wtentative-definition-compat`\n\nSilence problematic `-Weverything` warnings globally (in picky mode):\n- `-Wused-but-marked-unused` (88000+ hits) and\n  `-Wdisabled-macro-expansion` (2600+ hits).\n  Triggered by `typecheck-gcc.h` when building with clang 14+.\n  Maybe there exists a way to fix within that header?\n  Ref: https://discourse.llvm.org/t/removing-wused-but-marked-unused/55310\n- `-Wunsafe-buffer-usage`. clang 16+. 7000+ hits.\n  May be useful in theory, but such high volume of hits makes it\n  impractical to review and possibly address. Meant for C++.\n  Ref: https://clang.llvm.org/docs/SafeBuffers.html\n  Ref: https://stackoverflow.com/questions/77017567/how-to-fix-code-to-avoid-warning-wunsafe-buffer-usage\n  Ref: https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734\n  Ref: https://github.com/llvm/llvm-project/pull/111624\n- `-Wimplicit-void-ptr-cast`. clang 21+. 1700+ hits.\n  C++ warning, deemed pure noise.\n  Ref: https://github.com/curl/curl/issues/18470#issuecomment-3253506266\n- `-Wswitch-default` (180+ hits), `-Wswitch-enum` (190+ hits),\n  `-Wcovered-switch-default` (20+ hits).\n  Next to impossible to fix cleanly, esp. when the covered `case`\n  branches depend on compile-time options.\n- `-Wdocumentation-unknown-command` (8+ hits).\n  Triggered in a few sources. Seems arbitrary and bogus.\n- `-Wpadded` (550+ hits).\n- `-Wc++-keyword` on Windows, where it collides with `wchar_t`.\n  (100+ hits)\n  Ref: https://github.com/llvm/llvm-project/issues/155988\n- `-Wreserved-macro-identifier`. clang 13+. 5+ hits.\n  Sometimes it's necessary to set external macros that use\n  the reserved namespace. E.g. `_CRT_NONSTDC_NO_DEPRECATE`,\n  `__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__`, `__NO_NET_API`,\n  possibly `_REENTRANT`, and more.\n  It's not worth trying to silence them individually.\n- `-Wnonportable-system-include-path` with `clang-cl`.\n  It'd be broken by doing what the warning suggests.\n- `-Wformat-non-iso` for clang-cl.\n\nCMake `PICKY_COMPILER=ON` (the default) or `./configure`\n`--enable-warnings` (not the default) is required to enable these\nsilencing rules.\n\nAlso:\n- autotools, cmake: fix Apple clang and mainline llvm version translations.\n  Ref: https://en.wikipedia.org/wiki/Xcode#Toolchain_versions\n- autotools, cmake: enable `-Warray-compare` for clang 20+.\n  Follow-up to 4b7accda5ae3f2e663aa3f3853805241ef87c2fe #17196\n- cmake: fix to enable `-Wmissing-variable-declarations` at an earlier\n  clang version.\n- cmake: update internal logic to handle warning options with `+` in\n  them.\n- cmake: fix internal logic to match the whole option when looking\n  into `CMAKE_C_FLAGS` for custom-disabled warnings.\n\nFollow-up to b85cb8cb4e143d1615d4fcc1ce8f2f7b66453995 #18485\n\nCloses #18477\n","parents":["87cbeecee4118fa3dcc8a0179b1c3b43e4775cb4"],"tree_hash":"cab17b05b9d055407adb3f85c1770b445e5990a1"}