test-xvasprintf: silence compiler warnings
authorEric Blake <ebb9@byu.net>
Thu, 19 Nov 2009 15:51:13 +0000 (08:51 -0700)
committerEric Blake <ebb9@byu.net>
Fri, 20 Nov 2009 02:00:38 +0000 (19:00 -0700)
* tests/test-xvasprintf.c (test_xvasprintf, test_xasprintf): Mask
empty string from gcc.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
tests/test-xvasprintf.c

index b177d67..b30f038 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-19  Eric Blake  <ebb9@byu.net>
+
+       test-xvasprintf: silence compiler warnings
+       * tests/test-xvasprintf.c (test_xvasprintf, test_xasprintf): Mask
+       empty string from gcc.
+
 2009-11-19  Jim Meyering  <meyering@redhat.com>
 
        xfreopen: new module, from coreutils
index 229e3fd..cc70709 100644 (file)
@@ -65,10 +65,14 @@ test_xvasprintf (void)
       free (result);
     }
 
-  result = my_xasprintf ("");
-  ASSERT (result != NULL);
-  ASSERT (strcmp (result, "") == 0);
-  free (result);
+  {
+    /* Silence gcc warning about zero-length format string.  */
+    char *empty = "";
+    result = my_xasprintf (empty);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "") == 0);
+    free (result);
+  }
 
   result = my_xasprintf ("%s", "foo");
   ASSERT (result != NULL);
@@ -100,10 +104,14 @@ test_xasprintf ()
       free (result);
     }
 
-  result = xasprintf ("");
-  ASSERT (result != NULL);
-  ASSERT (strcmp (result, "") == 0);
-  free (result);
+  {
+    /* Silence gcc warning about zero-length format string.  */
+    char *empty = "";
+    result = xasprintf (empty);
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "") == 0);
+    free (result);
+  }
 
   result = xasprintf ("%s", "foo");
   ASSERT (result != NULL);