diff --git a/upnp/src/genlib/net/sock.c b/upnp/src/genlib/net/sock.c index a69ce9b..5aab91e 100644 --- a/upnp/src/genlib/net/sock.c +++ b/upnp/src/genlib/net/sock.c @@ -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;