Skip to content

src: silence compiler warnings 1 - #876

Closed
vszakats wants to merge 59 commits into
libssh2:masterfrom
vszakats:silence-warnings-1-1
Closed

vszakats wants to merge 59 commits into
libssh2:masterfrom
vszakats:silence-warnings-1-1

Conversation

@vszakats

@vszakats vszakats commented Mar 25, 2023 •

Copy link
Copy Markdown
Member

Most of the changes aim to silence warnings by adding casts.

An assortment of other issues, mainly compiler warnings, resolved:

  • unreachable code fixed by using goto in publickey_response_success() in publickey.c.
  • potentially uninitialized variable in sftp_open().
  • MSVS-specific bogus warnings with nid_type in kex.c.
  • check result of kex_session_ecdh_curve_type().
  • add missing function declarations.
  • type changes to fit values without casts:
    • cmd_len in scp_recv() and scp_send(): int → size_t
    • Blowfish_expandstate(), Blowfish_expand0state() loop counters: uint16_t → int
    • RECV_SEND_ALL(): int → ssize_t
    • shell_quotearg() → unsigned → size_t
    • sig_len in _libssh2_mbedtls_rsa_sha2_sign(): unsigned → size_t
    • prefs_len in libssh2_session_method_pref(): int → size_t
    • firstsec in _libssh2_debug_low(): int → long
    • method_len in libssh2_session_method_pref(): int → size_t
  • simplify _libssh2_ntohu64().
  • fix LIBSSH2_INT64_T_FORMAT for MinGW.
  • fix gcc warning by not using a bit field for burn_optimistic_kexinit.
  • fix unused variable warning in _libssh2_cipher_crypt() in libgcrypt.c.
  • fix unused variables with HAVE_DISABLED_NONBLOCKING.
  • avoid const stripping with BIO_new_mem_buf() and OpenSSL 1.0.2 and newer.
  • add a missing const in wincng.h.
  • FIXME added for public:
    • libssh2_channel_window_read_ex() read_avail argument type.
    • libssh2_base64_decode() datalen argument type.
  • formatting in wincng.h.

See warning details in the PR's individual commits.

Cherry-picked from #846
Closes #876


Partial list of warnings fixed:

gcc:

src/session.c: In function ‘libssh2_poll’:
src/session.c:1550:33: warning: conversion from ‘long unsigned int’ to ‘short int’ may change value [-Wconversion]
 1550 |             sockets[i].events = fds[i].events;
      |                                 ^~~

clang:

src/session.c:1550:40: warning: implicit conversion loses integer precision: 'unsigned long' to 'short' [-Wimplicit-int-conversion]
            sockets[i].events = fds[i].events;
                              ~ ~~~~~~~^~~~~~
src/kex.c:3761:44: warning: conversion from 'unsigned char' to 'unsigned char:1' may change value [-Wconversion]

gcc:

src/session.c: In function ‘_libssh2_wait_socket’:
src/session.c:658:53: warning: conversion from ‘long int’ to ‘int’ may change value [-Wconversion]
  658 |         rc = poll(sockets, 1, has_timeout?ms_to_next: -1);
      |                               ~~~~~~~~~~~~~~~~~~~~~~^~~~
src/session.c:1717:42: warning: conversion from ‘long int’ to ‘int’ may change value [-Wconversion]
 1717 |             sysret = poll(sockets, nfds, timeout_remaining);
      |                                          ^~~~~~~~~~~~~~~~~

clang:

src/session.c:658:43: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        rc = poll(sockets, 1, has_timeout?ms_to_next: -1);
             ~~~~                         ^~~~~~~~~~
src/session.c:1717:42: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
            sysret = poll(sockets, nfds, timeout_remaining);
                     ~~~~                ^~~~~~~~~~~~~~~~~

gcc:

/home/runner/work/libssh2/libssh2/src/blowfish.c: In function ‘Blowfish_expand0state’:
/home/runner/work/libssh2/libssh2/src/blowfish.c:442:36: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  442 |     for(i = 0; i < BLF_N + 2; i += 2) {
      |                                    ^
/home/runner/work/libssh2/libssh2/src/blowfish.c:450:34: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  450 |         for(k = 0; k < 256; k += 2) {
      |                                  ^
/home/runner/work/libssh2/libssh2/src/blowfish.c: In function ‘Blowfish_expandstate’:
/home/runner/work/libssh2/libssh2/src/blowfish.c:481:36: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  481 |     for(i = 0; i < BLF_N + 2; i += 2) {
      |                                    ^
/home/runner/work/libssh2/libssh2/src/blowfish.c:491:34: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  491 |         for(k = 0; k < 256; k += 2) {
      |                                  ^
src/bcrypt_pbkdf.c:91:26: warning: conversion from ‘uint32_t’ {aka ‘unsigned int’} to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
   91 |         out[4 * i + 3] = (cdata[i] >> 24) & 0xff;
      |                          ^
src/bcrypt_pbkdf.c: In function ‘bcrypt_pbkdf’:
src/bcrypt_pbkdf.c:139:34: warning: conversion from ‘uint32_t’ {aka ‘unsigned int’} to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
  139 |         countsalt[saltlen + 0] = (count >> 24) & 0xff;
      |                                  ^

gcc: (clang was OK)

scp.c: In function 'scp_send':
scp.c:1022:51: warning: ISO C does not support the 'I' printf flag [-Wformat=]
 1022 |                      LIBSSH2_SCP_RESPONSE_BUFLEN, "C0%o %"
      |                                                   ^~~~~~~~
scp.c:1022:51: warning: format '%d' expects argument of type 'int', but argument 5 has type 'libssh2_int64_t' {aka 'long long int'} [-Wformat=]
 1022 |                      LIBSSH2_SCP_RESPONSE_BUFLEN, "C0%o %"
      |                                                   ^~~~~~~~
 1023 |                      LIBSSH2_INT64_T_FORMAT " %s\n", mode,
 1024 |                      size, base);
      |                      ~~~~
      |                      |
      |                      libssh2_int64_t {aka long long int}
misc.c(168): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
misc.c(201): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
../src/misc.c:168:29: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'int' [-Wshorten-64-to-32]
    rc = recv(sock, buffer, length, flags);
         ~~~~               ^~~~~~
../src/misc.c:201:29: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'int' [-Wshorten-64-to-32]
    rc = send(sock, buffer, length, flags);
         ~~~~               ^~~~~~

clang:

../src/misc.c:239:9: warning: implicit conversion loses integer precision: 'unsigned long long' to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
        |  (libssh2_uint64_t) buf[3];
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/misc.c:243:9: warning: implicit conversion loses integer precision: 'unsigned long long' to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
        |  (libssh2_uint64_t) buf[7];
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/session.c:679:..: warning C4244: 'function': conversion from 'libssh2_socket_t' to 'int', possible loss of data
src/session.c:679:40: warning: conversion from 'libssh2_socket_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/session.c:679:40: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/session.c:1771:..: warning C4244: 'function': conversion from 'libssh2_socket_t' to 'int', possible loss of data
src/session.c:1771:35: warning: conversion from 'libssh2_socket_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/session.c:1771:35: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/misc.c:83:..: warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
src/knownhost.c:173:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/knownhost.c:173:42: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:173:42: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:173:42: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
src/knownhost.c:173:42: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
src/knownhost.c:180:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/knownhost.c:180:42: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:180:42: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:180:42: warning: implicit conversion loses integer precision: 'unsigned long long' to 'unsigned int' [-Wshorten-64-to-32]
src/knownhost.c:180:42: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
src/pem.c:394:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/pem.c:394:39: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/pem.c:394:39: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/pem.c:394:39: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
src/pem.c:394:39: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:614:..: warning C4244: 'function': conversion from '__int64' to 'unsigned int', possible loss of data
src/userauth.c:614:49: warning: conversion from 'long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:614:49: warning: conversion from 'long long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:614:49: warning: implicit conversion loses integer precision: 'long long' to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:614:49: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:718:..: warning C4244: 'function': conversion from '__int64' to 'unsigned int', possible loss of data
src/userauth.c:718:49: warning: conversion from 'long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:718:49: warning: conversion from 'long long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:718:49: warning: implicit conversion loses integer precision: 'long long' to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:718:49: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
src/kex.c:4046:..: warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
src/kex.c:1431:..: warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
src/kex.c:1559:..: warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
C:\projects\libssh2\src\misc.c(83): warning C4018: '<' : signed/unsigned mismatch [C:\projects\libssh2\_builds\src\libssh2.vcxproj]
C:\projects\libssh2\src\misc.c(83): warning C4018: '<' : signed/unsigned mismatch [C:\projects\libssh2\_builds\tests\test_keyboard_interactive_auth_info_request.vcxproj]

VS2015, OpenSSL, Shared:

c:\projects\libssh2\src\publickey.c(291): warning C4702: unreachable code

Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46504603/job/pb8gutsrqohot9ef#L175

src/agent.c:153:19: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:153:19: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:160:19: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:160:19: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:174:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:174:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:186:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:186:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:198:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:198:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:217:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:217:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/scp.c:261:..: warning C4244: 'return': conversion from '__int64' to 'unsigned int', possible loss of data
src/scp.c:261:16: warning: conversion from 'long int' to 'unsigned int' may change value [-Wconversion]
src/scp.c:261:16: warning: conversion from 'long long int' to 'unsigned int' may change value [-Wconversion]
src/scp.c:261:16: warning: implicit conversion loses integer precision: 'long long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:261:16: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:304:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/scp.c:304:64: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:304:64: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:304:64: warning: implicit conversion loses integer precision: 'unsigned long long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:304:64: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:863:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/scp.c:863:64: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:863:64: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:863:64: warning: implicit conversion loses integer precision: 'unsigned long long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:863:64: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:301:..: warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
src/scp.c:301:19: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:301:19: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:301:19: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/scp.c:301:19: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
src/scp.c:860:..: warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
src/scp.c:860:19: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:860:19: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:860:19: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/scp.c:860:19: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
src/misc.c:348:25: warning: conversion from 'int' to 'unsigned char' may change value [-Wconversion]
src/misc.c:352:25: warning: conversion from 'int' to 'unsigned char' may change value [-Wconversion]
src/misc.c:356:25: warning: conversion from 'int' to 'unsigned char' may change value [-Wconversion]
src/blowfish.c:549:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:553:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:571:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:575:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:595:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:599:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:621:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:625:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:637:15: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:641:15: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/kex.c:3959:..: warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
src/kex.c:3959:21: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/kex.c:3959:21: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
src/kex.c:3959:21: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/kex.c:3959:21: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
src/agent.c:314:..: warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data
src/agent.c:314:18: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'DWORD' {aka 'long unsigned int'} may change value [-Wconversion]
src/agent.c:314:20: warning: implicit conversion loses integer precision: 'unsigned long long' to 'DWORD' (aka 'unsigned long') [-Wshorten-64-to-32]
src/wincng.c:671:..: warning C4267: 'function': conversion from 'size_t' to 'ULONG', possible loss of data
src/wincng.c:671:39: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'ULONG' {aka 'long unsigned int'} may change value [-Wconversion]
src/wincng.c:671:39: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'ULONG' (aka 'unsigned long') [-Wshorten-64-to-32]
src/wincng.c:2552:33: warning: conversion from 'long long unsigned int' to 'DWORD' {aka 'long unsigned int'} may change value [-Warith-conversion]
src/libgcrypt.c:650:6: warning: no previous prototype for '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
src/libgcrypt.c:650:6: warning: no previous prototype for function '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
src/mbedtls.c:833:6: warning: no previous prototype for '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
src/mbedtls.c:833:6: warning: no previous prototype for function '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
src/kex.c:1719:..: warning C4701: potentially uninitialized local variable 'type' used
src/kex.c:2303:15: warning: 'type' may be used uninitialized [-Wmaybe-uninitialized]
src/openssl.c:207:..: warning C4701: potentially uninitialized local variable 'nid_type' used
src/openssl.c:208:..: warning C4701: potentially uninitialized local variable 'nid_type' used
src/openssl.c:355:..: warning C4701: potentially uninitialized local variable 'type' used
src/sftp.c:1201:25: warning: 'data_len' may be used uninitialized [-Wmaybe-uninitialized]
src/sftp.c:1202:30: warning: 'data' may be used uninitialized [-Wmaybe-uninitialized]
src/misc.c:519:24: warning: implicit conversion loses integer precision: '__darwin_time_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/session.c:665:52: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]

vszakats added 16 commits March 25, 2023 22:27
```
src/misc.c:519:24: warning: implicit conversion loses integer precision: '__darwin_time_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/session.c:665:52: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
```
```
src/kex.c:1719:..: warning C4701: potentially uninitialized local variable 'type' used
src/kex.c:2303:15: warning: 'type' may be used uninitialized [-Wmaybe-uninitialized]
src/openssl.c:207:..: warning C4701: potentially uninitialized local variable 'nid_type' used
src/openssl.c:208:..: warning C4701: potentially uninitialized local variable 'nid_type' used
src/openssl.c:355:..: warning C4701: potentially uninitialized local variable 'type' used
src/sftp.c:1201:25: warning: 'data_len' may be used uninitialized [-Wmaybe-uninitialized]
src/sftp.c:1202:30: warning: 'data' may be used uninitialized [-Wmaybe-uninitialized]
```
```
src/libgcrypt.c:650:6: warning: no previous prototype for '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
src/libgcrypt.c:650:6: warning: no previous prototype for function '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
src/mbedtls.c:833:6: warning: no previous prototype for '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
src/mbedtls.c:833:6: warning: no previous prototype for function '_libssh2_init_aes_ctr' [-Wmissing-prototypes]
```
```
src/agent.c:314:..: warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data
src/agent.c:314:18: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'DWORD' {aka 'long unsigned int'} may change value [-Wconversion]
src/agent.c:314:20: warning: implicit conversion loses integer precision: 'unsigned long long' to 'DWORD' (aka 'unsigned long') [-Wshorten-64-to-32]
src/wincng.c:671:..: warning C4267: 'function': conversion from 'size_t' to 'ULONG', possible loss of data
src/wincng.c:671:39: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'ULONG' {aka 'long unsigned int'} may change value [-Wconversion]
src/wincng.c:671:39: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'ULONG' (aka 'unsigned long') [-Wshorten-64-to-32]
src/wincng.c:2552:33: warning: conversion from 'long long unsigned int' to 'DWORD' {aka 'long unsigned int'} may change value [-Warith-conversion]
```
```
src/kex.c:3959:..: warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
src/kex.c:3959:21: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/kex.c:3959:21: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
src/kex.c:3959:21: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/kex.c:3959:21: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
```
```
src/blowfish.c:549:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:553:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:571:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:575:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:595:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:599:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:621:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:625:19: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:637:15: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
src/blowfish.c:641:15: warning: conversion from 'uint32_t' {aka 'unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion]
```
```
src/misc.c:348:25: warning: conversion from 'int' to 'unsigned char' may change value [-Wconversion]
src/misc.c:352:25: warning: conversion from 'int' to 'unsigned char' may change value [-Wconversion]
src/misc.c:356:25: warning: conversion from 'int' to 'unsigned char' may change value [-Wconversion]
```
```
src/scp.c:301:..: warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
src/scp.c:301:19: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:301:19: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:301:19: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/scp.c:301:19: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
src/scp.c:860:..: warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
src/scp.c:860:19: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:860:19: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
src/scp.c:860:19: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/scp.c:860:19: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
```
```
src/scp.c:261:..: warning C4244: 'return': conversion from '__int64' to 'unsigned int', possible loss of data
src/scp.c:261:16: warning: conversion from 'long int' to 'unsigned int' may change value [-Wconversion]
src/scp.c:261:16: warning: conversion from 'long long int' to 'unsigned int' may change value [-Wconversion]
src/scp.c:261:16: warning: implicit conversion loses integer precision: 'long long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:261:16: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:304:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/scp.c:304:64: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:304:64: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:304:64: warning: implicit conversion loses integer precision: 'unsigned long long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:304:64: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:863:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/scp.c:863:64: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:863:64: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/scp.c:863:64: warning: implicit conversion loses integer precision: 'unsigned long long' to 'unsigned int' [-Wshorten-64-to-32]
src/scp.c:863:64: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
```
```
src/agent.c:153:19: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:153:19: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:160:19: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:160:19: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:174:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:174:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:186:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:186:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:198:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:198:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
src/agent.c:217:14: warning: conversion from 'ssize_t' {aka 'long int'} to 'int' may change value [-Wconversion]
src/agent.c:217:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
```
@vszakats
vszakats force-pushed the silence-warnings-1-1 branch 2 times, most recently from 25845e2 to 9b3ab77 Compare March 26, 2023 00:41
vszakats added 12 commits March 26, 2023 00:48
```
C:\projects\libssh2\src\misc.c(83): warning C4018: '<' : signed/unsigned mismatch [C:\projects\libssh2\_builds\src\libssh2.vcxproj]
C:\projects\libssh2\src\misc.c(83): warning C4018: '<' : signed/unsigned mismatch [C:\projects\libssh2\_builds\tests\test_keyboard_interactive_auth_info_request.vcxproj]
```
```
src/kex.c:1431:..: warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
src/kex.c:1559:..: warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
```
```
src/kex.c:4046:..: warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
```
```
src/knownhost.c:173:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/knownhost.c:173:42: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:173:42: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:173:42: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
src/knownhost.c:173:42: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
src/knownhost.c:180:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/knownhost.c:180:42: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:180:42: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/knownhost.c:180:42: warning: implicit conversion loses integer precision: 'unsigned long long' to 'unsigned int' [-Wshorten-64-to-32]
src/knownhost.c:180:42: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Wshorten-64-to-32]
src/pem.c:394:..: warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
src/pem.c:394:39: warning: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/pem.c:394:39: warning: conversion from 'size_t' {aka 'long unsigned int'} to 'unsigned int' may change value [-Wconversion]
src/pem.c:394:39: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
src/pem.c:394:39: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:614:..: warning C4244: 'function': conversion from '__int64' to 'unsigned int', possible loss of data
src/userauth.c:614:49: warning: conversion from 'long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:614:49: warning: conversion from 'long long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:614:49: warning: implicit conversion loses integer precision: 'long long' to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:614:49: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:718:..: warning C4244: 'function': conversion from '__int64' to 'unsigned int', possible loss of data
src/userauth.c:718:49: warning: conversion from 'long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:718:49: warning: conversion from 'long long int' to 'unsigned int' may change value [-Wconversion]
src/userauth.c:718:49: warning: implicit conversion loses integer precision: 'long long' to 'unsigned int' [-Wshorten-64-to-32]
src/userauth.c:718:49: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
```
```
src/misc.c:83:..: warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
```
It's an unused arg on that platform.

```
src/session.c:679:..: warning C4244: 'function': conversion from 'libssh2_socket_t' to 'int', possible loss of data
src/session.c:679:40: warning: conversion from 'libssh2_socket_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/session.c:679:40: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
src/session.c:1771:..: warning C4244: 'function': conversion from 'libssh2_socket_t' to 'int', possible loss of data
src/session.c:1771:35: warning: conversion from 'libssh2_socket_t' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
src/session.c:1771:35: warning: implicit conversion loses integer precision: 'unsigned long long' to 'int' [-Wshorten-64-to-32]
```
vszakats added 13 commits March 26, 2023 00:48
```
src/bcrypt_pbkdf.c:91:26: warning: conversion from ‘uint32_t’ {aka ‘unsigned int’} to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
   91 |         out[4 * i + 3] = (cdata[i] >> 24) & 0xff;
      |                          ^
src/bcrypt_pbkdf.c: In function ‘bcrypt_pbkdf’:
src/bcrypt_pbkdf.c:139:34: warning: conversion from ‘uint32_t’ {aka ‘unsigned int’} to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Wconversion]
  139 |         countsalt[saltlen + 0] = (count >> 24) & 0xff;
      |                                  ^
```
```
/home/runner/work/libssh2/libssh2/src/blowfish.c: In function ‘Blowfish_expand0state’:
/home/runner/work/libssh2/libssh2/src/blowfish.c:442:36: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  442 |     for(i = 0; i < BLF_N + 2; i += 2) {
      |                                    ^
/home/runner/work/libssh2/libssh2/src/blowfish.c:450:34: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  450 |         for(k = 0; k < 256; k += 2) {
      |                                  ^
/home/runner/work/libssh2/libssh2/src/blowfish.c: In function ‘Blowfish_expandstate’:
/home/runner/work/libssh2/libssh2/src/blowfish.c:481:36: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  481 |     for(i = 0; i < BLF_N + 2; i += 2) {
      |                                    ^
/home/runner/work/libssh2/libssh2/src/blowfish.c:491:34: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Warith-conversion]
  491 |         for(k = 0; k < 256; k += 2) {
      |                                  ^
```
gcc
```
src/session.c: In function ‘_libssh2_wait_socket’:
src/session.c:658:53: warning: conversion from ‘long int’ to ‘int’ may change value [-Wconversion]
  658 |         rc = poll(sockets, 1, has_timeout?ms_to_next: -1);
      |                               ~~~~~~~~~~~~~~~~~~~~~~^~~~
src/session.c:1717:42: warning: conversion from ‘long int’ to ‘int’ may change value [-Wconversion]
 1717 |             sysret = poll(sockets, nfds, timeout_remaining);
      |                                          ^~~~~~~~~~~~~~~~~
```

clang
```
src/session.c:658:43: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        rc = poll(sockets, 1, has_timeout?ms_to_next: -1);
             ~~~~                         ^~~~~~~~~~
src/session.c:1717:42: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
            sysret = poll(sockets, nfds, timeout_remaining);
                     ~~~~                ^~~~~~~~~~~~~~~~~
```
```
src/kex.c:3761:44: warning: conversion from 'unsigned char' to 'unsigned char:1' may change value [-Wconversion]
```
gcc
```
src/session.c: In function ‘libssh2_poll’:
src/session.c:1550:33: warning: conversion from ‘long unsigned int’ to ‘short int’ may change value [-Wconversion]
 1550 |             sockets[i].events = fds[i].events;
      |                                 ^~~
```

clang
```
src/session.c:1550:40: warning: implicit conversion loses integer precision: 'unsigned long' to 'short' [-Wimplicit-int-conversion]
            sockets[i].events = fds[i].events;
                              ~ ~~~~~~~^~~~~~
```
@vszakats
vszakats force-pushed the silence-warnings-1-1 branch from 9b3ab77 to 3c48bc3 Compare March 26, 2023 00:50
@vszakats vszakats closed this in 02f2700 Mar 26, 2023
@vszakats
vszakats deleted the silence-warnings-1-1 branch March 26, 2023 09:40
vszakats added a commit that referenced this pull request Mar 26, 2023
Apply type changes to avoid casts and warnings. In most cases this
means changing to a larger type, usually `size_t` or `ssize_t`.

Change signedness in a few places.

Also introduce new variables to avoid reusing them for multiple
purposes, to avoid casts and warnings.

- add FIXME for public `libssh2_sftp_readdir_ex()` return type.

- fix `_libssh2_mbedtls_rsa_sha2_verify()` to verify if `sig_len`
  is large enough.

- fix `_libssh2_dh_key_pair()` in `wincng.c` to return error if
  `group_order` input is negative.

  Maybe we should also reject zero?

- bump `_libssh2_random()` size type `int` -> `size_t`. Add checks
  for WinCNG and OpenSSL to return error if requested more than they
  support (`ULONG_MAX`, `INT_MAX` respectively).

- change `_libssh2_ntohu32()` return value `unsigned int` -> `uint32_t`.

- fix `_libssh2_mbedtls_bignum_random()` to check for a negative `top`
  input.

- size down `_libssh2_wincng_key_sha_verify()` `hashlen` to match
  Windows'.

- fix `session_disconnect()` to limit length of `lang_len`
  (to 256 bytes).

- fix bad syntax in an `assert()`.

- add a few `const` to casts.

- `while(1)` -> `for(;;)`.

- add casts that didn't fit into #876.

- update `docs/HACKING-CRYPTO` with new sizes.

May need review for OS400QC3: /cc @monnerat @jonrumsey

See warning details in the PR's individual commits.

Cherry-picked from #846
Closes #879
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jun 5, 2023
Simplify the code to avoid this warning. This might also
help to avoid this with other compilers.

Improves 02f2700 libssh2#876
Might fix libssh2#1083
Closes libssh2#1086
vszakats added a commit that referenced this pull request Jun 6, 2023
Simplify the code to avoid this warning. This might also help avoiding
it with other compilers (e.g. gcc?).

Improves 02f2700 #876
Might fix #1083
Closes #1086
vszakats added a commit that referenced this pull request Jun 13, 2023
Before 02f2700 #846 #876, we used
`%I64d'. That patch changed this to `%lld`. This patch uses `PRId64`
(defined in `inttypes.h`).

Fixes #1090
Closes #1091
lampmanyao pushed a commit to lampmanyao/libssh2 that referenced this pull request Jul 16, 2023
Simplify the code to avoid this warning. This might also help avoiding
it with other compilers (e.g. gcc?).

Improves 02f2700 libssh2#876
Might fix libssh2#1083
Closes libssh2#1086
lampmanyao pushed a commit to lampmanyao/libssh2 that referenced this pull request Jul 16, 2023
Before 02f2700 libssh2#846 libssh2#876, we used
`%I64d'. That patch changed this to `%lld`. This patch uses `PRId64`
(defined in `inttypes.h`).

Fixes libssh2#1090
Closes libssh2#1091
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Most of the changes aim to silence warnings by adding casts.

An assortment of other issues, mainly compiler warnings, resolved:

- unreachable code fixed by using `goto` in
  `publickey_response_success()` in `publickey.c`.

- potentially uninitialized variable in `sftp_open()`.

- MSVS-specific bogus warnings with `nid_type` in `kex.c`.

- check result of `kex_session_ecdh_curve_type()`.

- add missing function declarations.

- type changes to fit values without casts:
  - `cmd_len` in `scp_recv()` and `scp_send()`: `int` -> `size_t`
  - `Blowfish_expandstate()`, `Blowfish_expand0state()` loop counters:
    `uint16_t` -> `int`
  - `RECV_SEND_ALL()`: `int` -> `ssize_t`
  - `shell_quotearg()` -> `unsigned` -> `size_t`
  - `sig_len` in `_libssh2_mbedtls_rsa_sha2_sign()`:
    `unsigned` -> `size_t`
  - `prefs_len` in `libssh2_session_method_pref()`: `int` -> `size_t`
  - `firstsec` in `_libssh2_debug_low()`: `int` -> `long`
  - `method_len` in `libssh2_session_method_pref()`: `int` -> `size_t`

- simplify `_libssh2_ntohu64()`.

- fix `LIBSSH2_INT64_T_FORMAT` for MinGW.

- fix gcc warning by not using a bit field for
  `burn_optimistic_kexinit`.

- fix unused variable warning in `_libssh2_cipher_crypt()` in
  `libgcrypt.c`.

- fix unused variables with `HAVE_DISABLED_NONBLOCKING`.

- avoid const stripping with `BIO_new_mem_buf()` and OpenSSL 1.0.2 and
  newer.

- add a missing const in `wincng.h`.

- FIXME added for public:
  - `libssh2_channel_window_read_ex()` `read_avail` argument type.
  - `libssh2_base64_decode()` `datalen` argument type.

- fix possible overflow in `sftp_read()`.

  Ref: 4552c73

- formatting in `wincng.h`.

See warning details in the PR's individual commits.

Cherry-picked from libssh2#846
Closes libssh2#876
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Apply type changes to avoid casts and warnings. In most cases this
means changing to a larger type, usually `size_t` or `ssize_t`.

Change signedness in a few places.

Also introduce new variables to avoid reusing them for multiple
purposes, to avoid casts and warnings.

- add FIXME for public `libssh2_sftp_readdir_ex()` return type.

- fix `_libssh2_mbedtls_rsa_sha2_verify()` to verify if `sig_len`
  is large enough.

- fix `_libssh2_dh_key_pair()` in `wincng.c` to return error if
  `group_order` input is negative.

  Maybe we should also reject zero?

- bump `_libssh2_random()` size type `int` -> `size_t`. Add checks
  for WinCNG and OpenSSL to return error if requested more than they
  support (`ULONG_MAX`, `INT_MAX` respectively).

- change `_libssh2_ntohu32()` return value `unsigned int` -> `uint32_t`.

- fix `_libssh2_mbedtls_bignum_random()` to check for a negative `top`
  input.

- size down `_libssh2_wincng_key_sha_verify()` `hashlen` to match
  Windows'.

- fix `session_disconnect()` to limit length of `lang_len`
  (to 256 bytes).

- fix bad syntax in an `assert()`.

- add a few `const` to casts.

- `while(1)` -> `for(;;)`.

- add casts that didn't fit into libssh2#876.

- update `docs/HACKING-CRYPTO` with new sizes.

May need review for OS400QC3: /cc @monnerat @jonrumsey

See warning details in the PR's individual commits.

Cherry-picked from libssh2#846
Closes libssh2#879
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Simplify the code to avoid this warning. This might also help avoiding
it with other compilers (e.g. gcc?).

Improves 02f2700 libssh2#876
Might fix libssh2#1083
Closes libssh2#1086
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Before 02f2700 libssh2#846 libssh2#876, we used
`%I64d'. That patch changed this to `%lld`. This patch uses `PRId64`
(defined in `inttypes.h`).

Fixes libssh2#1090
Closes libssh2#1091
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