mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
src: silence compiler warnings 1
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: 4552c73cd5
- formatting in `wincng.h`.
See warning details in the PR's individual commits.
Cherry-picked from #846
Closes #876
This commit is contained in:
@@ -164,10 +164,11 @@ struct iovec {
|
||||
#include "crypto.h"
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* Force parameter type. */
|
||||
#define recv(s, b, l, f) recv((s), (b), (int)(l), (f))
|
||||
#define send(s, b, l, f) send((s), (b), (int)(l), (f))
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
@@ -201,20 +202,23 @@ struct iovec {
|
||||
#define LIBSSH2_FREE(session, ptr) \
|
||||
session->free((ptr), &(session)->abstract)
|
||||
#define LIBSSH2_IGNORE(session, data, datalen) \
|
||||
session->ssh_msg_ignore((session), (data), (datalen), &(session)->abstract)
|
||||
session->ssh_msg_ignore((session), (data), (int)(datalen), \
|
||||
&(session)->abstract)
|
||||
#define LIBSSH2_DEBUG(session, always_display, message, message_len, \
|
||||
language, language_len) \
|
||||
session->ssh_msg_debug((session), (always_display), (message), \
|
||||
(message_len), (language), (language_len), \
|
||||
session->ssh_msg_debug((session), (always_display), \
|
||||
(message), (int)(message_len), \
|
||||
(language), (int)(language_len), \
|
||||
&(session)->abstract)
|
||||
#define LIBSSH2_DISCONNECT(session, reason, message, message_len, \
|
||||
language, language_len) \
|
||||
session->ssh_msg_disconnect((session), (reason), (message), \
|
||||
(message_len), (language), (language_len), \
|
||||
session->ssh_msg_disconnect((session), (reason), \
|
||||
(message), (int)(message_len), \
|
||||
(language), (int)(language_len), \
|
||||
&(session)->abstract)
|
||||
|
||||
#define LIBSSH2_MACERROR(session, data, datalen) \
|
||||
session->macerror((session), (data), (datalen), &(session)->abstract)
|
||||
session->macerror((session), (data), (int)(datalen), &(session)->abstract)
|
||||
#define LIBSSH2_X11_OPEN(channel, shost, sport) \
|
||||
channel->session->x11(((channel)->session), (channel), \
|
||||
(shost), (sport), (&(channel)->session->abstract))
|
||||
@@ -633,7 +637,7 @@ struct _LIBSSH2_SESSION
|
||||
|
||||
/* Agreed Key Exchange Method */
|
||||
const LIBSSH2_KEX_METHOD *kex;
|
||||
unsigned int burn_optimistic_kexinit:1;
|
||||
unsigned int burn_optimistic_kexinit;
|
||||
|
||||
unsigned char *session_id;
|
||||
uint32_t session_id_len;
|
||||
@@ -1142,7 +1146,7 @@ void _libssh2_init_if_needed(void);
|
||||
#define ARRAY_SIZE(a) (sizeof ((a)) / sizeof ((a)[0]))
|
||||
|
||||
/* define to output the libssh2_int64_t type in a *printf() */
|
||||
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#if defined(__BORLANDC__) || defined(_MSC_VER)
|
||||
#define LIBSSH2_INT64_T_FORMAT "I64d"
|
||||
#else
|
||||
#define LIBSSH2_INT64_T_FORMAT "lld"
|
||||
|
||||
Reference in New Issue
Block a user