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

@ -214,11 +214,12 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
rc = libssh2_poll(fds, nfds, 0);
if(rc >0) {
rc = libssh2_channel_read(channel, buf, bufsize);
write(sock, buf, rc);
ssize_t nread;
nread = libssh2_channel_read(channel, buf, bufsize);
write(sock, buf, nread);
}
rc = select(sock + 1, &set, NULL, NULL, &timeval_out);
rc = select((int)(sock + 1), &set, NULL, NULL, &timeval_out);
if(rc > 0) {
memset((void *)buf, 0, bufsize);
@ -247,7 +248,7 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
int
main (int argc, char *argv[])
{
unsigned long hostaddr = 0;
uint32_t hostaddr = 0;
int sock = 0;
int rc = 0;
struct sockaddr_in sin;
@ -448,7 +449,7 @@ main (int argc, char *argv[])
}
rc = select(fileno(stdin) + 1, &set, NULL, NULL, &timeval_out);
rc = select((int)(fileno(stdin) + 1), &set, NULL, NULL, &timeval_out);
if(rc > 0) {
/* Data in stdin*/
rc = read(fileno(stdin), buf, 1);