Skip to content

build: update picky warning options, fix fallouts - #1972

Closed
vszakats wants to merge 31 commits into
libssh2:masterfrom
vszakats:warnsup
Closed

vszakats wants to merge 31 commits into
libssh2:masterfrom
vszakats:warnsup

Conversation

@vszakats

@vszakats vszakats commented Jun 4, 2026 •

Copy link
Copy Markdown
Member
  • sync picky compiler warning options with curl:
    • update version mappings for latest Apple clang.
    • replace -pedantic with -Wpedantic on newer toolchains.
    • adjust warning cutoff versions.
    • enable new picky warnings.
    • unlock picky warnings for most recent MSVC.
  • GHA: bump some MSVC jobs to to VS2026.

Fix fallouts:

  • configure: replace -I with -isystem for dependency headers.
    Notably it silences picky warnings otherwise found in 3rd-party
    headers, e.g. -Wreserved-identifier in gpg-error.h,
    openssl/lhash.h, wolfssl/wolfcrypt/hmac.h, or
    -Wcast-function-type-strict in openssl/rsa.h.
    It also aligns autotools builds with CMake (and curl builds).
    Logic copied from curl.
  • example/x11: fix to not use reserved symbols.
  • include, src/libssh2_priv.h: silence -Wreserved-identifier locally.
    May be fixed for real in a future patch.
  • avoid using reserved C++ keyword public.
  • openssl: silence -Wcast-function-type-strict locally for
    non-OpenSSL3 builds.
  • mbedtls, openssl: fix potentially uninitialized variable warnings.
    (extend to all compilers from MSVC in openssl)
  • fix LIBSSH2_SOCKET_MASK signedness on Windows.
  • wincng: apply casts from int to enum to silence
    -Wimplicit-int-enum-cast.
  • configure: disable -Wleading-whitespace=spaces to due
    incompatibility with AC_FUNC_ALLOCA.
  • packet: fix to pass int as mask length.
  • fix -Wformat-signedness.
  • src/libssh2_priv.h: silence -Wreserved-macro-identifier locally for
    mingw-w64 builds.
  • GHA: add workaround for missing NSIS on windows-2025 runner images.

@vszakats
vszakats marked this pull request as draft June 4, 2026 18:22
@vszakats vszakats changed the title build: update picky warning options, fix fallouts, build: update picky warning options, fix fallouts Jun 4, 2026
@vszakats
vszakats force-pushed the warnsup branch 3 times, most recently from 9e60df9 to fd879ff Compare June 4, 2026 22:12
@vszakats
vszakats marked this pull request as ready for review June 5, 2026 03:54
@vszakats
vszakats force-pushed the warnsup branch 4 times, most recently from 662a2ae to ea05f25 Compare June 6, 2026 19:39
vszakats added 11 commits June 7, 2026 14:08
```
../../src/wincng.c:1905:28: error: implicit conversion from 'unsigned int' to enumeration type 'ssh2_curve_type' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
 1905 |             point->curve = curve;
      |                          ~ ^~~~~
../../src/wincng.c:2501:26: error: implicit conversion from 'unsigned int' to enumeration type 'ssh2_curve_type' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
 2501 |             *out_curve = curve;
      |                        ~ ^~~~~
```
https://github.com/libssh2/libssh2/actions/runs/26973976594/job/79596136811?pr=1972
… and autoconf

```
In file included from ../../src/libssh2_setup.h:21,
                 from ../../src/libssh2_priv.h:56,
                 from ../../src/bcrypt_pbkdf.c:20:
../src/libssh2_config.h:190:8: error: whitespace other than spaces in leading whitespace [-Werror=leading-whitespace=]
  190 |         STACK_DIRECTION > 0 => grows toward higher addresses
../src/libssh2_config.h:191:8: error: whitespace other than spaces in leading whitespace [-Werror=leading-whitespace=]
  191 |         STACK_DIRECTION < 0 => grows toward lower addresses
../src/libssh2_config.h:192:8: error: whitespace other than spaces in leading whitespace [-Werror=leading-whitespace=]
  192 |         STACK_DIRECTION = 0 => direction of growth unknown */
In file included from ../../src/libssh2_setup.h:21,
                 from ../../src/libssh2_priv.h:56,
                 from ../../src/channel.c:42:
../src/libssh2_config.h:190:8: error: whitespace other than spaces in leading whitespace [-Werror=leading-whitespace=]
  190 |         STACK_DIRECTION > 0 => grows toward higher addresses
../src/libssh2_config.h:191:8: error: whitespace other than spaces in leading whitespace [-Werror=leading-whitespace=]
  191 |         STACK_DIRECTION < 0 => grows toward lower addresses
../src/libssh2_config.h:192:8: error: whitespace other than spaces in leading whitespace [-Werror=leading-whitespace=]
  192 |         STACK_DIRECTION = 0 => direction of growth unknown */
In file included from ../../src/libssh2_setup.h:21,
                 from ../../src/libssh2_priv.h:56,
                 from ../../src/agent.c:42:
```
https://github.com/libssh2/libssh2/actions/runs/26981291885/job/79620874898?pr=1972

libssh2_config.h (see tabs):
```
/* Define to the version of this package. */

/* If using the C implementation of alloca, define if you know the
   direction of stack growth for your system; otherwise it will be
   automatically deduced at runtime.
	STACK_DIRECTION > 0 => grows toward higher addresses
	STACK_DIRECTION < 0 => grows toward lower addresses
	STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */

/* Define to 1 if all of the C89 standard headers exist (not just the ones
   required in a freestanding environment). This macro is provided for
   backward compatibility; new code need not use it. */
```
vszakats added 6 commits June 7, 2026 14:08
```
/home/runner/work/libssh2/libssh2/src/libssh2_setup.h:65:10: error: macro name is a reserved identifier [clang-diagnostic-reserved-macro-identifier,-warnings-as-errors]
   65 | #  undef _FILE_OFFSET_BITS
      |          ^
```
This reverts commit 23582343112c61a42b653a5f1c9ee746e3d292ca.
```
D:\a\libssh2\libssh2\src\channel.c(1356,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\channel.c(1356,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(373,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\channel.c(1356,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(373,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\channel.c(1356,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1080,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(373,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1083,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(373,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1086,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1080,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1089,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1083,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1102,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1086,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1105,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1089,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1108,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1102,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1111,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1105,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\misc.c(89,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1108,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\misc.c(89,1): warning C4710: 'fprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\knownhost.c(1111,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\misc.c(89,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\misc.c(89,1): warning C4710: 'fprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1282,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1282,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1282,1): warning C4710: 'packet_queue_listener': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1282,1): warning C4710: 'packet_queue_listener': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1295,1): warning C4710: 'packet_x11_open': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1295,1): warning C4710: 'packet_x11_open': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1310,1): warning C4710: 'packet_authagent_open': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\packet.c(1310,1): warning C4710: 'packet_authagent_open': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(310,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(310,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(310,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(310,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(855,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(855,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(956,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(956,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(1026,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\scp.c(1026,1): warning C4710: 'snprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\session.c(714,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
D:\a\libssh2\libssh2\src\session.c(714,1): error C2220: the following warning is treated as an error [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\session.c(714,1): warning C4710: 'fprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_static.vcxproj]
D:\a\libssh2\libssh2\src\session.c(714,1): warning C4710: 'fprintf': function not inlined [D:\a\libssh2\libssh2\bld\src\libssh2_shared.vcxproj]
 ```
vszakats added 6 commits June 7, 2026 14:14
looks like windows-2025 images no longer include NSIS, which may cause this:
```
[...]
 test_auth_pubkey_ok_ed25519_mem.vcxproj -> D:\a\libssh2\libssh2\bld\tests\Release\test_auth_pubkey_ok_ed25519_mem.exe
  test_auth_pubkey_ok_ecdsa.vcxproj -> D:\a\libssh2\libssh2\bld\tests\Release\test_auth_pubkey_ok_ecdsa.exe
  Building Custom Rule D:/a/libssh2/libssh2/CMakeLists.txt
  1>
EXEC : CPack error : Cannot find NSIS compiler makensis: likely it is not installed, or not in your PATH [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
EXEC : CPack error : Could not read NSIS registry value. This is usually caused by NSIS not being installed. Please install NSIS from http://nsis.sourceforge.net [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
EXEC : CPack error : Cannot initialize the generator NSIS [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: The command "setlocal [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: cd D:\a\libssh2\libssh2\bld [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: D: [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: "C:\Program Files\CMake\bin\cpack.exe" -C Release --config ./CPackConfig.cmake [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmEnd [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmErrorLevel [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: exit /b %1 [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmDone [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Microsoft\VC\v180\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" exited with code 1. [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
Error: Process completed with exit code 1.
```
https://github.com/libssh2/libssh2/actions/runs/27092197028/job/79957682891?pr=1972

https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-VS2026-Readme.md
previous solution worked, trying something less drastic hopefully
This reverts commit 8d7e43b.

Not working:
```
EXEC : CPack error : CPack generator not specified [D:\a\libssh2\libssh2\bld\PACKAGE.vcxproj]
```
https://github.com/libssh2/libssh2/actions/runs/27092973593/job/79959882409
@vszakats vszakats closed this in 04ecdb2 Jun 7, 2026
@vszakats
vszakats deleted the warnsup branch June 7, 2026 13:20
vszakats added a commit that referenced this pull request Jun 7, 2026
vszakats added a commit that referenced this pull request Jun 7, 2026
Turns out the logic was there but for gcc only. Drop in favor of the
more generic solution merged recently.

Follow-up to 04ecdb2 #1972

Closes #1993
vszakats added a commit that referenced this pull request Jun 7, 2026
Drop local worker functions, to avoid passing around function pointers,
with a local typedef that needs to be different (and matching upstream
exactly) dependening  on crypto backend/version and key type.

Also:
- fix ed25519 callback function for non-OpenSSL3.
  (detected by MSVC after dropping casts.)
- drop local compiler warning silencing.
- tried to use local macros. It saved 30 lines of code, but I opted for
  the simplicity/clarity of duplicating the BIO calls around each call.

Follow-up to 04ecdb2 #1972
Follow-up to 784446b #1484
Follow-up to b0ab005 #1207
Follow-up to 231a97a

Closes #1991
vszakats added a commit that referenced this pull request Jun 7, 2026
To avoid building NSIS packages, which seems not super useful,
and breaks without NSIS (as seen in CI).

Do what curl does and restrict CPack to TGZ.

Follow-up to 04ecdb2 #1972

Closes #1996
vszakats added a commit that referenced this pull request Jun 22, 2026
Also:
- drop no longer used env.
  Follow-up to c528dfd #1996

Ref: actions/runner-images#14017
Follow-up to 04ecdb2 #1972

Closes #2119
vszakats added a commit that referenced this pull request Jul 15, 2026
…ntf mask

- configure: fix wrong guard for `-Wno-c++-keyword`.
  Follow-up to 04ecdb2 #1972

- sync most outlier `FILE *` variables names with rest of code.

- agent: replace cast with accurate printf mask when forming
  `PageantRequest` map name.
  Follow-up to 7b351ee

Closes #2317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant