[or-cvs] try to fix bug with spurious "everything is broken" warning

Nick Mathewson nickm at seul.org
Mon Feb 13 00:26:45 UTC 2006


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv7359/src/common

Modified Files:
	util.c 
Log Message:
try to fix bug with spurious "everything is broken" warning

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -p -d -r1.245 -r1.246
--- util.c	12 Feb 2006 23:58:22 -0000	1.245
+++ util.c	13 Feb 2006 00:26:43 -0000	1.246
@@ -1426,8 +1426,12 @@ int
 addr_mask_get_bits(uint32_t mask)
 {
   int i;
+  if (mask == 0)
+    return 0;
+  if (mask == 0xFFFFFFFFu)
+    return 32;
   for (i=0; i<=32; ++i) {
-    if (mask == ~((1<<(32-i))-1)) {
+    if (mask == (uint32_t) ~((1u<<(32-i))-1)) {
       return i;
     }
   }
@@ -1493,7 +1497,7 @@ parse_addr_and_port_range(const char *s,
              "Bad number of mask bits on address range; rejecting.");
         goto err;
       }
-      *mask_out = ~((1<<(32-bits))-1);
+      *mask_out = ~((1u<<(32-bits))-1);
     } else if (tor_inet_aton(mask, &in) != 0) {
       *mask_out = ntohl(in.s_addr);
     } else {



More information about the tor-commits mailing list