1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-31 00:03:08 +03:00

example, tests: address compiler warnings

Fix or silence all C compiler warnings discovered with (or without)
`PICKY_COMPILER=ON` (in CMake). This means all warnings showing up in
CI (gcc, clang, MSVS 2013/2015), in local tests on macOS (clang 14) and
Windows cross-builds using gcc (12) and llvm/clang (14/15).

Also fix the expression `nread -= nread` in `sftp_RW_nonblock.c`.

Cherry-picked from: #846
Closes #861
This commit is contained in:
Viktor Szakats
2023-03-20 15:46:12 +00:00
parent ec0a51db1f
commit b13936bd6a
47 changed files with 343 additions and 262 deletions

View File

@ -56,13 +56,13 @@ enum {
static int netconf_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t len)
{
int i;
ssize_t i;
ssize_t wr = 0;
do {
i = libssh2_channel_write(channel, buf, len);
if(i < 0) {
fprintf(stderr, "libssh2_channel_write: %d\n", i);
fprintf(stderr, "libssh2_channel_write: %d\n", (int)i);
return -1;
}
wr += i;
@ -71,8 +71,8 @@ static int netconf_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t len)
return 0;
}
static int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
char *buf, size_t buflen)
static ssize_t netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
char *buf, size_t buflen)
{
ssize_t len;
size_t rd = 0;
@ -202,7 +202,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "\n");
/* check what authentication methods are available */
userauthlist = libssh2_userauth_list(session, username, strlen(username));
userauthlist = libssh2_userauth_list(session, username,
(unsigned int)strlen(username));
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
if(strstr(userauthlist, "password"))
auth |= AUTH_PASSWORD;