Skip to content

build fixes and improvements (mostly for Windows) - #808

Closed
vszakats wants to merge 34 commits into
libssh2:masterfrom
vszakats:warn1
Closed

vszakats wants to merge 34 commits into
libssh2:masterfrom
vszakats:warn1

Conversation

@vszakats

@vszakats vszakats commented Mar 1, 2023 •

Copy link
Copy Markdown
Member
  • in hostkey.c check the result of libssh2_sha256_init() and
    libssh2_sha512_init() calls. This avoid the warning that we're
    ignoring the return values.

  • fix code using int (or SOCKET) for sockets. Use libssh2's
    dedicated libssh2_socket_t and LIBSSH2_INVALID_SOCKET instead.

  • fix compiler warnings due to STATUS_* macro redefinitions between
    ntstatus.h / winnt.h. Solve it by manually defining the single
    STATUS value we need from ntstatus.h and stop including the whole
    header.
    Fixes Fix macro redefinition warnings on MSVC #733

  • improve Windows UWP/WinRT builds by detecting it with code copied
    from the curl project. Then excluding problematic libssh2 parts
    according to PR by Dmitry Kostjučenko.
    Fixes Fix compile for Windows UWP/WinRT platform. #734

  • always use SecureZeroMemory() on Windows.

    We can tweak this if not found or not inlined by a C compiler which
    we otherwise support. Same if it causes issues with UWP apps.

    Ref: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)
    Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlsecurezeromemory

  • always enable LIBSSH2_CLEAR_MEMORY on Windows. CMake and
    curl-for-win builds already did that. Delete SecureZeroMemory()
    detection from autotools' WinCNG backend logic, that this
    setting used to depend on.

    TODO: Enable it for all platforms in a separate PR.
    TODO: For clearing buffers in WinCNG, call _libssh2_explicit_zero(),
    insead of a local function or explicit SecureZeroMemory().

  • Makefile.inc: move os400qc3.h to HEADERS. This fixes
    compilation on non-unixy platforms. Recent regression.

  • libssh2.rc: replace copyright with plain ASCII, as in curl.

    Ref: curl/curl@1ca62bb
    Ref: Compiling with Clang on Windows fails at libcurl.rc curl/curl#7765
    Ref: libcurl.rc: switch out the copyright symbol for plain ASCII curl/curl#7776

  • CMake fixes and improvements:

  • win32/GNUmakefile fixes and improvements:

    • delete _AMD64_ and add missing -m64 for x64 builds under test.
    • add support for ARCH=custom.
      It disables hardcoded Intel 64-bit and Intel 32-bit options,
      allowing ARM64 builds.
    • add support for LIBSSH2_RCFLAG_EXTRAS.
      To pass custom options to windres, e.g. in ARM64 builds.
    • add support for LIBSSH2_RC. To override windres.
    • delete support for Metrowerks C. Last released in 2004.
  • win32/libssh2_config.h: delete unnecessary socket #includes

    src/libssh2_priv.h includes winsock2.h and ws2tcpip.h further
    down the line, triggered by HAVE_WINSOCK2_H.

    mswsock.h does not seem to be necessary anymore.

    Double-including these (before windows.h) caused compiler failures
    when building against BoringSSL and warnings with LibreSSL. We could
    work this around by passing -DNOCRYPT. Deleting the duplicates
    fixes these issues.

    Timeline:
    2013: c910cd3 deleted mswsock.h from src/libssh2_priv.h
    2008: 8c43bc5 added winsock2.h and ws2tcpip.h to src/libssh2_priv.h
    2005: dc4bb1a added the now deleted #includes

  • delete or replace LIBSSH2_WIN32 with WIN32.

  • replace hand-rolled HAVE_WINDOWS_H macro with WIN32. Also delete
    its detections/definitions.

  • delete unused LIBSSH2_DARWIN macro.

  • delete unused writev() Windows implementation

    There is no reference to writev() since 2007-02-02, commit
    9d55db6.

  • fix a bunch of MSVC / llvm/clang / gcc compiler warnings:

    • warning C4100: '...': unreferenced formal parameter
    • using value of undefined PP macro LIBSSH2DEBUG
    • missing void from function definition
    • if() block missing in non-debug builds
    • unreferenced variable in non-debug builds
    • warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]
      in _libssh2_debug()
    • warning C4295: 'ciphertext' : array is too small to include a terminating null character
    • warning C4706: assignment within conditional expression
    • warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
      By suppressning it. Would be best to use inet_pton() as suggested.
      On Windows this needs Vista though.
    • warning C4152: nonstandard extension, function/data pointer conversion in expression
      (silenced locally)
    • warning C4068: unknown pragma

    Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46354480/job/j7d0m34qgq8rag5w

@vszakats vszakats changed the title fix compiler warnings WIP: fix compiler warnings Mar 1, 2023
@vszakats
vszakats marked this pull request as draft March 1, 2023 14:34
@vszakats vszakats changed the title WIP: fix compiler warnings fix compiler warnings Mar 1, 2023
@vszakats vszakats changed the title fix compiler warnings fix Windows compile issues Mar 1, 2023
@vszakats vszakats changed the title fix Windows compile issues fix Windows build issues Mar 1, 2023
@vszakats
vszakats force-pushed the warn1 branch 7 times, most recently from 9bd21aa to 15eecfa Compare March 2, 2023 00:13
@willco007

Copy link
Copy Markdown
Member

This all looks good so far, thanks for all this work!

@vszakats
vszakats force-pushed the warn1 branch 2 times, most recently from 318ae0f to 84e875a Compare March 2, 2023 01:26
@vszakats

vszakats commented Mar 2, 2023

Copy link
Copy Markdown
Member Author

Thank you @willco007!

vszakats added 2 commits March 2, 2023 02:46
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntstatus.h(2232):
   warning C4005: 'STATUS_INVALID_DISPOSITION': macro redefinition [C:\projects\libssh2\_builds\src\libssh2.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(2240):
   note: see previous definition of 'STATUS_INVALID_DISPOSITION'

Ref: libssh2#733
@vszakats
vszakats marked this pull request as ready for review March 2, 2023 02:55
@vszakats
vszakats force-pushed the warn1 branch 2 times, most recently from c9b5e56 to 52a9c08 Compare March 2, 2023 03:43
@vszakats

vszakats commented Mar 2, 2023 •

Copy link
Copy Markdown
Member Author

What still needs to be addressed, but in a future PR:

  • Bumping up warnings in autotools builds. CI uses these, so it'd be useful.
  • Fixing the many -Wconversion warnings, some cast-induced alignment warnings, and printf mask issues.
  • Enabling LIBSSH2_CLEAR_MEMORY for non-Windows systems. I have a patch for that.
  • Some Windows tests on AppVeyor seem flaky. They also exit after the first flakiness.

vszakats added a commit to curl/curl-for-win that referenced this pull request Mar 2, 2023
vszakats added a commit to curl/curl-for-win that referenced this pull request Mar 2, 2023
LibreSSL doesn't seem to need NOCRYPT with cmake/autotools builds.

With GNU Make builds an uptream fix is coming up, making NOCRYPT
unnecessary.

Ref: libssh2/libssh2#808
Detection logic copied from curl.

Original PR libssh2#734,
by Dmitry Kostjučenko
@dfandrich

dfandrich commented Mar 2, 2023 via email

Copy link
Copy Markdown
Contributor

vszakats added 17 commits March 2, 2023 21:21
CMake and curl-for-win builds already did that.

TODO: Enable it for all platforms in a separate PR.
Such setting disables the hardcoded Intel 64-bit and Intel 32-bit
settings, and allow building for ARM64 or any custom config.
To pass custom options to windres, for example for ARCH=custom
targets.
To override windres.
The last reference to writev() was deleted in commit
9d55db6 (2007-02-02)
`winsock2.h` and `ws2tcpip.h` are included further down the line from
`src/libssh2_priv.h` due to `HAVE_WINSOCK2_H`.

`mswsock.h` does not seem to be necessary anymore.

Double-including these (before `windows.h`) caused compiler failures
when building against BoringSSL and warnings with LibreSSL. It could
be worked around by passing `-DNOCRYPT`. Deleting the duplicates fixes
these issues.

Timeline:
2013: c910cd3 deletes `mswsock.h` from `src/libssh2_priv.h`
2008: 8c43bc5 adds `winsock2.h` and `ws2tcpip.h` to `src/libssh2_priv.h`
2005: dc4bb1a adds the now deleted #includes
As known from curl. ON by default.

It controls both the newly added picky warnings for llvm/clang and gcc,
and also the pre-existing ones for MSVC.
Even though the MSDN page of this function does not list it as UWP
compatible, this function is an alias for RtlSecureZeroMemory(). Doc [1]
for the latter says that the function is inlined, so it's safe to use
regardless of Windows version. mingw-w64-generated objects also confirm
that. libssh2 also had that unconditionally enabled in WinCNG with no
report of issues. It's likely dependent on compiler version, but more
half-decently modern ones should support it.

Make a leap and use it unconditionally in _libssh2_explicit_zero().

[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlsecurezeromemory
@vszakats vszakats changed the title fix Windows build issues build fixes and improvements (for Windows mostly) Mar 3, 2023
@vszakats vszakats changed the title build fixes and improvements (for Windows mostly) build fixes and improvements (mostly for Windows) Mar 3, 2023
@vszakats vszakats closed this in 2addafb Mar 3, 2023
@vszakats
vszakats deleted the warn1 branch March 9, 2023 19:00
vszakats added a commit to vszakats/libssh2 that referenced this pull request Dec 1, 2023
It looks like NTSTATUS values are mapped to two different types
inside Windows headers:

./winnt.h:#define STATUS_NO_MEMORY ((DWORD)0xC0000017)
./ntstatus.h:#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)

Of which `winnt.h` is the portable and the wrong one at the same time.

A variation of this issue came up earlier in
2addafb libssh2#808
vszakats added a commit to vszakats/libssh2 that referenced this pull request Dec 1, 2023
By replacing `int` with `NTSTATUS`.

```
src/wincng.c:1339:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1656:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1659:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2102:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2273:27: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2276:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2697:22: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/7060704458/job/19220774229#step:6:165

Turns out the above isn't enough (or may not even be strictly
necessary), because NTSTATUS values are mapped to two different types
inside public Windows headers:

./winnt.h:#define STATUS_NO_MEMORY ((DWORD)0xC0000017)
./ntstatus.h:#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)

Of which `winnt.h` is the portable and the wrong one at the same time.

A variation of this issue came up earlier in
2addafb libssh2#808

Fix this by casting these Windows constants to `NTSTATUS`.
vszakats added a commit to vszakats/libssh2 that referenced this pull request Dec 1, 2023
By replacing `int` with `NTSTATUS`.

```
src/wincng.c:1339:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1656:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1659:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2102:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2273:27: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2276:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2697:22: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/7060704458/job/19220774229#step:6:165

Turns out the above isn't enough (or may not even be strictly
necessary), because NTSTATUS values are mapped to two different types
inside public Windows headers:

./winnt.h:#define STATUS_NO_MEMORY ((DWORD)0xC0000017)
./ntstatus.h:#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)

Of which `winnt.h` is the portable and the wrong one at the same time.

A variation of this issue came up earlier in
2addafb libssh2#808

Fix this by casting these Windows constants to `NTSTATUS`.
vszakats added a commit to vszakats/libssh2 that referenced this pull request Dec 1, 2023
By replacing `int` with `NTSTATUS`.

```
src/wincng.c:1339:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1656:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1659:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2102:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2273:27: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2276:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2697:22: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/7060704458/job/19220774229#step:6:165

Turns out the above isn't enough (or may not even be strictly
necessary), because NTSTATUS values are mapped to two different types
inside public Windows headers:

./winnt.h:#define STATUS_NO_MEMORY ((DWORD)0xC0000017)
./ntstatus.h:#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)

Of which `winnt.h` is the portable and the wrong one at the same time.

A variation of this issue came up earlier in
2addafb libssh2#808

Fix this by casting these Windows constants to `NTSTATUS`.
vszakats added a commit to vszakats/libssh2 that referenced this pull request Dec 2, 2023
By replacing `int` with `NTSTATUS`.

```
src/wincng.c:1339:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1656:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1659:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2102:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2273:27: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2276:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2697:22: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/7060704458/job/19220774229#step:6:165

Turns out the above isn't enough (or may not even be strictly
necessary), because NTSTATUS values are mapped to two different types
inside public Windows headers:

./winnt.h:#define STATUS_NO_MEMORY ((DWORD)0xC0000017)
./ntstatus.h:#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)

Of which `winnt.h` is the portable and the wrong one at the same time.

A variation of this issue came up earlier in
2addafb libssh2#808

Fix this by casting these Windows constants to `NTSTATUS`.
vszakats added a commit to vszakats/libssh2 that referenced this pull request Dec 2, 2023
By replacing `int` with `NTSTATUS`.

```
src/wincng.c:1339:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1656:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:1659:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2102:19: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2273:27: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2276:23: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
src/wincng.c:2697:22: warning: signed conversion from 'long unsigned int' to 'int' changes value from '3221225495' to '-1073741801' [-Wsign-conversion]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/7060704458/job/19220774229#step:6:165

Turns out the above isn't enough (or may not even be strictly
necessary), because NTSTATUS values are mapped to two different types
inside public Windows headers:

./winnt.h:#define STATUS_NO_MEMORY ((DWORD)0xC0000017)
./ntstatus.h:#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)

Of which `winnt.h` is the portable and the wrong one at the same time.

A variation of this issue came up earlier in
2addafb libssh2#808

Fix this by casting these Windows constants to `NTSTATUS`.
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
- in `hostkey.c` check the result of `libssh2_sha256_init()` and
  `libssh2_sha512_init()` calls. This avoid the warning that we're
  ignoring the return values.

- fix code using `int` (or `SOCKET`) for sockets. Use libssh2's
  dedicated `libssh2_socket_t` and `LIBSSH2_INVALID_SOCKET` instead.

- fix compiler warnings due to `STATUS_*` macro redefinitions between
  `ntstatus.h` / `winnt.h`. Solve it by manually defining the single
  `STATUS` value we need from `ntstatus.h` and stop including the whole
  header.
  Fixes libssh2#733

- improve Windows UWP/WinRT builds by detecting it with code copied
  from the curl project. Then excluding problematic libssh2 parts
  according to PR by Dmitry Kostjučenko.
  Fixes libssh2#734

- always use `SecureZeroMemory()` on Windows.

  We can tweak this if not found or not inlined by a C compiler which
  we otherwise support. Same if it causes issues with UWP apps.

  Ref: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)
  Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlsecurezeromemory

- always enable `LIBSSH2_CLEAR_MEMORY` on Windows. CMake and
  curl-for-win builds already did that. Delete `SecureZeroMemory()`
  detection from autotools' WinCNG backend logic, that this
  setting used to depend on.

  TODO: Enable it for all platforms in a separate PR.
  TODO: For clearing buffers in WinCNG, call `_libssh2_explicit_zero()`,
        insead of a local function or explicit `SecureZeroMemory()`.

- Makefile.inc: move `os400qc3.h` to `HEADERS`. This fixes
  compilation on non-unixy platforms. Recent regression.

- `libssh2.rc`: replace copyright with plain ASCII, as in curl.

  Ref: curl/curl@1ca62bb
  Ref: curl/curl#7765
  Ref: curl/curl#7776

- CMake fixes and improvements:

  - enable warnings with llvm/clang.
  - enable more comprehensive warnings with gcc and llvm/clang.
    Logic copied from curl:
    https://github.com/curl/curl/blob/233810bb5f6c5e7bedfc10bdd36607b958c0cfe4/CMakeLists.txt#L131-L148
  - fix `Policy CMP0080` CMake warning by deleting that reference.
  - add `ENABLE_WERROR` (default: `OFF`) option. Ported from curl.
  - add `PICKY_COMPILER` (default: `ON`) option, as known from curl.

    It controls both the newly added picky warnings for llvm/clang and
    gcc, and also the pre-existing ones for MSVC.

- `win32/GNUmakefile` fixes and improvements:

  - delete `_AMD64_` and add missing `-m64` for x64 builds under test.
  - add support for `ARCH=custom`.
    It disables hardcoded Intel 64-bit and Intel 32-bit options,
    allowing ARM64 builds.
  - add support for `LIBSSH2_RCFLAG_EXTRAS`.
    To pass custom options to windres, e.g. in ARM64 builds.
  - add support for `LIBSSH2_RC`. To override `windres`.
  - delete support for Metrowerks C. Last released in 2004.

- `win32/libssh2_config.h`: delete unnecessary socket #includes

  `src/libssh2_priv.h` includes `winsock2.h` and `ws2tcpip.h` further
   down the line, triggered by `HAVE_WINSOCK2_H`.

  `mswsock.h` does not seem to be necessary anymore.

  Double-including these (before `windows.h`) caused compiler failures
  when building against BoringSSL and warnings with LibreSSL. We could
  work this around by passing `-DNOCRYPT`. Deleting the duplicates
  fixes these issues.

  Timeline:
  2013: c910cd3 deleted `mswsock.h` from `src/libssh2_priv.h`
  2008: 8c43bc5 added `winsock2.h` and `ws2tcpip.h` to `src/libssh2_priv.h`
  2005: dc4bb1a added the now deleted #includes

- delete or replace `LIBSSH2_WIN32` with `WIN32`.

- replace hand-rolled `HAVE_WINDOWS_H` macro with `WIN32`. Also delete
  its detections/definitions.

- delete unused `LIBSSH2_DARWIN` macro.

- delete unused `writev()` Windows implementation

  There is no reference to `writev()` since 2007-02-02, commit
  9d55db6.

- fix a bunch of MSVC / llvm/clang / gcc compiler warnings:

  - `warning C4100: '...': unreferenced formal parameter`
  - using value of undefined PP macro `LIBSSH2DEBUG`
  - missing void from function definition
  - `if()` block missing in non-debug builds
  - unreferenced variable in non-debug builds
  - `warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]`
    in `_libssh2_debug()`
  - `warning C4295: 'ciphertext' : array is too small to include a terminating null character`
  - `warning C4706: assignment within conditional expression`
  - `warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or
      define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings`
    By suppressning it. Would be best to use inet_pton() as suggested.
    On Windows this needs Vista though.
  - `warning C4152: nonstandard extension, function/data pointer conversion in expression`
    (silenced locally)
  - `warning C4068: unknown pragma`

  Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46354480/job/j7d0m34qgq8rag5w

Closes libssh2#808
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.

3 participants