Fix for compiler warning
src/genlib/net/sock.c: In function ‘sock_read_write’:
src/genlib/net/sock.c:172:4: warning: conversion to ‘long int’ from
‘size_t’ may change the sign of the result
(forward port of commit f1c4ffefda
)
This commit is contained in:
parent
461a478c25
commit
4cd4b1789f
@ -162,8 +162,8 @@ static int sock_read_write(
|
|||||||
time_t start_time = time(NULL);
|
time_t start_time = time(NULL);
|
||||||
SOCKET sockfd = info->socket;
|
SOCKET sockfd = info->socket;
|
||||||
long bytes_sent = 0;
|
long bytes_sent = 0;
|
||||||
long byte_left = 0;
|
size_t byte_left = 0;
|
||||||
long num_written;
|
ssize_t num_written;
|
||||||
|
|
||||||
if (*timeoutSecs < 0)
|
if (*timeoutSecs < 0)
|
||||||
return UPNP_E_TIMEDOUT;
|
return UPNP_E_TIMEDOUT;
|
||||||
@ -216,17 +216,17 @@ static int sock_read_write(
|
|||||||
} else {
|
} else {
|
||||||
byte_left = bufsize;
|
byte_left = bufsize;
|
||||||
bytes_sent = 0;
|
bytes_sent = 0;
|
||||||
while (byte_left > 0) {
|
while (byte_left != 0) {
|
||||||
#ifdef UPNP_ENABLE_OPEN_SSL
|
#ifdef UPNP_ENABLE_OPEN_SSL
|
||||||
if (info->ssl) {
|
if (info->ssl) {
|
||||||
num_written = SSL_write(info->ssl,
|
num_written = SSL_write(info->ssl,
|
||||||
buffer + bytes_sent, (size_t)byte_left);
|
buffer + bytes_sent, byte_left);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
/* write data. */
|
/* write data. */
|
||||||
num_written = send(sockfd,
|
num_written = send(sockfd,
|
||||||
buffer + bytes_sent, (size_t)byte_left,
|
buffer + bytes_sent, byte_left,
|
||||||
MSG_DONTROUTE | MSG_NOSIGNAL);
|
MSG_DONTROUTE | MSG_NOSIGNAL);
|
||||||
#ifdef UPNP_ENABLE_OPEN_SSL
|
#ifdef UPNP_ENABLE_OPEN_SSL
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ static int sock_read_write(
|
|||||||
#endif
|
#endif
|
||||||
return (int)num_written;
|
return (int)num_written;
|
||||||
}
|
}
|
||||||
byte_left = byte_left - num_written;
|
byte_left -= (size_t)num_written;
|
||||||
bytes_sent += num_written;
|
bytes_sent += num_written;
|
||||||
}
|
}
|
||||||
numBytes = bytes_sent;
|
numBytes = bytes_sent;
|
||||||
|
Loading…
Reference in New Issue
Block a user