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:
Marcelo Roberto Jimenez 2012-03-13 14:57:22 -03:00
parent 461a478c25
commit 4cd4b1789f

View File

@ -162,8 +162,8 @@ static int sock_read_write(
time_t start_time = time(NULL);
SOCKET sockfd = info->socket;
long bytes_sent = 0;
long byte_left = 0;
long num_written;
size_t byte_left = 0;
ssize_t num_written;
if (*timeoutSecs < 0)
return UPNP_E_TIMEDOUT;
@ -216,17 +216,17 @@ static int sock_read_write(
} else {
byte_left = bufsize;
bytes_sent = 0;
while (byte_left > 0) {
while (byte_left != 0) {
#ifdef UPNP_ENABLE_OPEN_SSL
if (info->ssl) {
num_written = SSL_write(info->ssl,
buffer + bytes_sent, (size_t)byte_left);
buffer + bytes_sent, byte_left);
}
else {
#endif
/* write data. */
num_written = send(sockfd,
buffer + bytes_sent, (size_t)byte_left,
buffer + bytes_sent, byte_left,
MSG_DONTROUTE | MSG_NOSIGNAL);
#ifdef UPNP_ENABLE_OPEN_SSL
}
@ -238,7 +238,7 @@ static int sock_read_write(
#endif
return (int)num_written;
}
byte_left = byte_left - num_written;
byte_left -= (size_t)num_written;
bytes_sent += num_written;
}
numBytes = bytes_sent;