[tor-commits] [torsocks/master] Suppress signed/unsigned comparison warnings with justified casts.

dgoulet at torproject.org dgoulet at torproject.org
Mon Jun 13 21:14:03 UTC 2016


commit 9b146f3762744c02d7646596e396dda149a0d61e
Author: Taylor R Campbell <campbell+torsocks at mumble.net>
Date:   Tue Jun 16 20:37:12 2015 +0000

    Suppress signed/unsigned comparison warnings with justified casts.
---
 tests/test_fd_passing.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/test_fd_passing.c b/tests/test_fd_passing.c
index e5eb10f..70d3fef 100644
--- a/tests/test_fd_passing.c
+++ b/tests/test_fd_passing.c
@@ -137,6 +137,8 @@ static ssize_t recv_unix_sock(int sock, void *buf, size_t len)
 	ssize_t ret = -1;
 	size_t len_last;
 
+	assert(len <= SSIZE_MAX);
+
 	memset(&msg, 0, sizeof(msg));
 
 	iov[0].iov_base = buf;
@@ -150,9 +152,10 @@ static ssize_t recv_unix_sock(int sock, void *buf, size_t len)
 		if (ret > 0) {
 			iov[0].iov_base += ret;
 			iov[0].iov_len -= ret;
-			assert(ret <= len_last);
+			assert((size_t)ret <= len_last);
 		}
-	} while ((ret > 0 && ret < len_last) || (ret < 0 && errno == EINTR));
+	} while ((ret > 0 && (size_t)ret < len_last) ||
+	    (ret < 0 && errno == EINTR));
 	if (ret < 0) {
 		perror("recvmsg");
 	} else if (ret > 0) {





More information about the tor-commits mailing list