1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00

Fix a couple of warnings of errors in MSVC builds

Two warnings (in tests & examples) in particular would cause problems:
bad format causing invalid data output or a bad chdir due to out of
scope buffer use.
This commit is contained in:
Dan Fandrich
2023-02-22 14:35:49 -08:00
parent 4c9ed51f96
commit d8220ddbff
10 changed files with 14 additions and 17 deletions

View File

@ -231,7 +231,6 @@ int main(int argc, char *argv[])
while(got < fileinfo.st_size) {
char mem[1024*24];
int rc;
do {
int amount = sizeof(mem);

View File

@ -48,10 +48,10 @@ int main(int argc, char *argv[])
size_t nread;
char *ptr;
struct stat fileinfo;
int err;
#ifdef WIN32
WSADATA wsadata;
int err;
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
if(err != 0) {
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
if(!channel) {
char *errmsg;
int errlen;
int err = libssh2_session_last_error(session, &errmsg, &errlen, 0);
err = libssh2_session_last_error(session, &errmsg, &errlen, 0);
fprintf(stderr, "Unable to open a session: (%d) %s\n", err, errmsg);
goto shutdown;
}

View File

@ -37,7 +37,7 @@
#include <ctype.h>
#ifdef WIN32
#define __FILESIZE "I64"
#define __FILESIZE "I64u"
#else
#define __FILESIZE "llu"
#endif

View File

@ -37,7 +37,7 @@
#include <ctype.h>
#ifdef WIN32
#define __FILESIZE "I64"
#define __FILESIZE "I64u"
#else
#define __FILESIZE "llu"
#endif

View File

@ -225,7 +225,6 @@ int main(int argc, char *argv[])
}
for(;;) {
/* loop until we block */
int rc;
do {
char buffer[0x4000];
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );

View File

@ -250,8 +250,8 @@ int main(int argc, char *argv[])
fds[0].events = LIBSSH2_POLLFD_POLLIN | LIBSSH2_POLLFD_POLLOUT;
do {
int rc = (libssh2_poll(fds, 1, 10));
int act = 0;
rc = (libssh2_poll(fds, 1, 10));
if(rc < 1)
continue;

View File

@ -254,7 +254,6 @@ int main(int argc, char *argv[])
}
for(;;) {
/* loop until we block */
int rc;
do {
char buffer[0x4000];
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );

View File

@ -65,7 +65,7 @@ bcrypt_hash(uint8_t *sha2pass, uint8_t *sha2salt, uint8_t *out)
uint32_t cdata[BCRYPT_BLOCKS];
int i;
uint16_t j;
size_t shalen = SHA512_DIGEST_LENGTH;
uint16_t shalen = SHA512_DIGEST_LENGTH;
/* key expansion */
Blowfish_initstate(&state);

View File

@ -1392,7 +1392,7 @@ _libssh2_packet_requirev(LIBSSH2_SESSION *session,
if(strchr((char *) packet_types, ret)) {
/* Be lazy, let packet_ask pull it out of the brigade */
int ret = _libssh2_packet_askv(session, packet_types, data,
ret = _libssh2_packet_askv(session, packet_types, data,
data_len, match_ofs, match_buf,
match_len);
state->start = 0;

View File

@ -81,6 +81,11 @@ static int connect_to_server(void)
static void setup_fixture_workdir(void)
{
#ifdef WIN32
char wd_buf[_MAX_PATH];
#else
char wd_buf[MAXPATHLEN];
#endif
char *wd = getenv("FIXTURE_WORKDIR");
#ifdef FIXTURE_WORKDIR
if(!wd) {
@ -88,11 +93,6 @@ static void setup_fixture_workdir(void)
}
#endif
if(!wd) {
#ifdef WIN32
char wd_buf[_MAX_PATH];
#else
char wd_buf[MAXPATHLEN];
#endif
getcwd(wd_buf, sizeof(wd_buf));
wd = wd_buf;
}