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

@ -42,7 +42,7 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
uint32_t hostaddr;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
@ -171,7 +171,7 @@ int main(int argc, char *argv[])
/* Send a file via scp. The mode parameter must only have permissions! */
channel = libssh2_scp_send(session, scppath, fileinfo.st_mode & 0777,
(unsigned long)fileinfo.st_size);
(size_t)fileinfo.st_size);
if(!channel) {
char *errmsg;
@ -191,16 +191,17 @@ int main(int argc, char *argv[])
ptr = mem;
do {
ssize_t nwritten;
/* write the same data over and over, until error or completion */
rc = libssh2_channel_write(channel, ptr, nread);
if(rc < 0) {
fprintf(stderr, "ERROR %d\n", rc);
nwritten = libssh2_channel_write(channel, ptr, nread);
if(nwritten < 0) {
fprintf(stderr, "ERROR %d\n", (int)nwritten);
break;
}
else {
/* rc indicates how many bytes were written this time */
ptr += rc;
nread -= rc;
/* nwritten indicates how many bytes were written this time */
ptr += nwritten;
nread -= nwritten;
}
} while(nread);