]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix compilation warnings in tor_addr_make_null patch
authorNick Mathewson <nickm@torproject.org>
Mon, 3 Mar 2014 15:00:37 +0000 (10:00 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 3 Mar 2014 15:05:02 +0000 (10:05 -0500)
There was one "missing prototype" warning because the test function
wasn't static, and one "unused parameter" warning about the "data"
parameter.

Also, I added a couple of tests to make sure that the "make_null"
addresses really were the addresses we expected, by formatting them
as strings.

src/test/test_addr.c

index f9213439790a1c4fb1dd1896c6f1c16d9b35bbfd..036380fe85a6d337fa9fd45fd769ae37877dedac 100644 (file)
@@ -971,11 +971,13 @@ test_addr_is_loopback(void *data)
   ;
 }
 
-void
+static void
 test_addr_make_null(void *data)
 {
   tor_addr_t *addr = tor_malloc(sizeof(*addr));
-  tor_addr_t *zeros = tor_calloc(1, sizeof(*addr));
+  tor_addr_t *zeros = tor_malloc_zero(sizeof(*addr));
+  char buf[TOR_ADDR_BUF_LEN];
+  (void) data;
   /* Ensure that before tor_addr_make_null, addr != 0's */
   memset(addr, 1, sizeof(*addr));
   tt_int_op(memcmp(addr, zeros, sizeof(*addr)), !=, 0);
@@ -983,11 +985,13 @@ test_addr_make_null(void *data)
   zeros->family = AF_INET;
   tor_addr_make_null(addr, AF_INET);
   tt_int_op(memcmp(addr, zeros, sizeof(*addr)), ==, 0);
+  tt_str_op(tor_addr_to_str(buf, addr, sizeof(buf), 0), ==, "0.0.0.0");
   /* Test with AF == AF_INET6 */
   memset(addr, 1, sizeof(*addr));
   zeros->family = AF_INET6;
   tor_addr_make_null(addr, AF_INET6);
   tt_int_op(memcmp(addr, zeros, sizeof(*addr)), ==, 0);
+  tt_str_op(tor_addr_to_str(buf, addr, sizeof(buf), 0), ==, "::");
  done:
   tor_free(addr);
   tor_free(zeros);