INN commit: branches/2.5/tests/lib (md5-t.c tst-t.c)

INN Commit rra at isc.org
Thu Apr 23 14:51:16 UTC 2015


    Date: Thursday, April 23, 2015 @ 07:51:16
  Author: iulius
Revision: 9828

Fix GCC 5.1.0 warning for incompatible pointer type

Rename the "U" macro used by two tests to "SUC" (casting to String of
Unsigned Chars) because it otherwise conflicts with how Unicode strings
are declared in ISO C11, the new default mode for the GCC 5 series.

Modified:
  branches/2.5/tests/lib/md5-t.c
  branches/2.5/tests/lib/tst-t.c

---------+
 md5-t.c |   35 +++++++++++++++++-----------------
 tst-t.c |   63 +++++++++++++++++++++++++++++++-------------------------------
 2 files changed, 50 insertions(+), 48 deletions(-)

Modified: md5-t.c
===================================================================
--- md5-t.c	2015-04-23 14:50:38 UTC (rev 9827)
+++ md5-t.c	2015-04-23 14:51:16 UTC (rev 9828)
@@ -7,8 +7,9 @@
 #include "inn/libinn.h"
 #include "libtest.h"
 
-/* Used to initialize strings of unsigned characters. */
-#define U       (const unsigned char *)
+/* Used for strings of unsigned characters (called SUC instead of U
+   because it otherwise conflicts with Unicode strings). */
+#define SUC       (const unsigned char *)
 
 /* An unsigned char version of strlen. */
 #define ustrlen(s)      strlen((const char *) s)
@@ -21,25 +22,25 @@
    checked separately. */
 static const unsigned char * const testdata[] = {
     /* First five tests of the MD5 test suite from RFC 1321. */
-    U"",
-    U"a",
-    U"abc",
-    U"message digest",
-    U"abcdefghijklmnopqrstuvwxyz",
+    SUC"",
+    SUC"a",
+    SUC"abc",
+    SUC"message digest",
+    SUC"abcdefghijklmnopqrstuvwxyz",
 
     /* Three real message IDs to ensure compatibility with old INN versions;
        the corresponding MD5 hashes were taken directly out of the history
        file of a server running INN 2.3. */
-    U"<J3Ds5.931$Vg6.7556 at news01.chello.no>",
-    U"<sr5v7ooea6e17 at corp.supernews.com>",
-    U"<cancel.Y2Ds5.26391$oH5.540535 at news-east.usenetserver.com>",
+    SUC"<J3Ds5.931$Vg6.7556 at news01.chello.no>",
+    SUC"<sr5v7ooea6e17 at corp.supernews.com>",
+    SUC"<cancel.Y2Ds5.26391$oH5.540535 at news-east.usenetserver.com>",
 
     /* Other random stuff, including high-bit characters. */
-    U"example.test",
-    U"||",
-    U"|||",
-    U"\375\277\277\277\277\276",
-    U"\377\277\277\277\277\277"
+    SUC"example.test",
+    SUC"||",
+    SUC"|||",
+    SUC"\375\277\277\277\277\276",
+    SUC"\377\277\277\277\277\277"
 };
 
 /* The hashes corresonding to the above data. */
@@ -95,8 +96,8 @@
 
     test_init(12 + ARRAY_SIZE(testdata));
 
-    test_md5(1, "93b885adfe0da089cdf634904fd59f71", U"\0", 1);
-    test_md5(2, "e94a053c3fbfcfb22b4debaa11af7718", U"\0ab\n", 4);
+    test_md5(1, "93b885adfe0da089cdf634904fd59f71", SUC"\0", 1);
+    test_md5(2, "e94a053c3fbfcfb22b4debaa11af7718", SUC"\0ab\n", 4);
 
     data = xmalloc(64 * 1024);
     memset(data, 0, 64 * 1024);

Modified: tst-t.c
===================================================================
--- tst-t.c	2015-04-23 14:50:38 UTC (rev 9827)
+++ tst-t.c	2015-04-23 14:51:16 UTC (rev 9828)
@@ -9,8 +9,9 @@
 #include "inn/libinn.h"
 #include "libtest.h"
 
-/* Used for strings of unsigned characters. */
-#define U (const unsigned char *)
+/* Used for strings of unsigned characters (called SUC instead of U
+   because it otherwise conflicts with Unicode strings). */
+#define SUC (const unsigned char *)
 
 /* An unsigned char version of strlen. */
 #define ustrlen(s) strlen((const char *) s)
@@ -36,38 +37,38 @@
 
     tst = tst_init(2);
     ok(1, tst != NULL);
-    ok(2, tst_insert(tst, U"test", test, 0, NULL) == TST_OK);
-    ok_string(3, "test", tst_search(tst, U"test"));
-    ok(4, tst_insert(tst, U"test", foo, 0, &existing) == TST_DUPLICATE_KEY);
+    ok(2, tst_insert(tst, SUC"test", test, 0, NULL) == TST_OK);
+    ok_string(3, "test", tst_search(tst, SUC"test"));
+    ok(4, tst_insert(tst, SUC"test", foo, 0, &existing) == TST_DUPLICATE_KEY);
     ok_string(5, "test", existing);
-    ok(6, tst_insert(tst, U"test", foo, TST_REPLACE, &existing) == TST_OK);
+    ok(6, tst_insert(tst, SUC"test", foo, TST_REPLACE, &existing) == TST_OK);
     ok_string(7, "test", existing);
-    ok_string(8, "foo", tst_search(tst, U"test"));
-    ok(9, tst_insert(tst, U"testing", testing, 0, NULL) == TST_OK);
-    ok(10, tst_insert(tst, U"t", t, 0, NULL) == TST_OK);
-    ok(11, tst_insert(tst, U"Strange", Strange, 0, NULL) == TST_OK);
-    ok(12, tst_insert(tst, U"çhange", change, 0, NULL) == TST_OK);
-    ok(13, tst_insert(tst, U"", foo, 0, NULL) == TST_NULL_KEY);
+    ok_string(8, "foo", tst_search(tst, SUC"test"));
+    ok(9, tst_insert(tst, SUC"testing", testing, 0, NULL) == TST_OK);
+    ok(10, tst_insert(tst, SUC"t", t, 0, NULL) == TST_OK);
+    ok(11, tst_insert(tst, SUC"Strange", Strange, 0, NULL) == TST_OK);
+    ok(12, tst_insert(tst, SUC"çhange", change, 0, NULL) == TST_OK);
+    ok(13, tst_insert(tst, SUC"", foo, 0, NULL) == TST_NULL_KEY);
     ok(14, tst_insert(tst, NULL, foo, 0, NULL) == TST_NULL_KEY);
-    ok_string(15, "testing", tst_search(tst, U"testing"));
-    ok_string(16, "t", tst_search(tst, U"t"));
-    ok_string(17, "Strange", tst_search(tst, U"Strange"));
-    ok_string(18, "çhange", tst_search(tst, U"çhange"));
-    ok_string(19, "foo", tst_search(tst, U"test"));
-    ok(20, tst_search(tst, U"") == NULL);
-    ok(21, tst_search(tst, U"Peter") == NULL);
-    ok(22, tst_search(tst, U"foo") == NULL);
-    ok(23, tst_search(tst, U"te") == NULL);
-    ok_string(24, "Strange", tst_delete(tst, U"Strange"));
-    ok(25, tst_search(tst, U"Strange") == NULL);
-    ok_string(26, "t", tst_delete(tst, U"t"));
-    ok(27, tst_search(tst, U"t") == NULL);
-    ok_string(28, "testing", tst_search(tst, U"testing"));
-    ok_string(29, "foo", tst_search(tst, U"test"));
-    ok_string(30, "testing", tst_delete(tst, U"testing"));
-    ok_string(31, "foo", tst_search(tst, U"test"));
-    ok_string(32, "çhange", tst_delete(tst, U"çhange"));
-    ok_string(33, "foo", tst_delete(tst, U"test"));
+    ok_string(15, "testing", tst_search(tst, SUC"testing"));
+    ok_string(16, "t", tst_search(tst, SUC"t"));
+    ok_string(17, "Strange", tst_search(tst, SUC"Strange"));
+    ok_string(18, "çhange", tst_search(tst, SUC"çhange"));
+    ok_string(19, "foo", tst_search(tst, SUC"test"));
+    ok(20, tst_search(tst, SUC"") == NULL);
+    ok(21, tst_search(tst, SUC"Peter") == NULL);
+    ok(22, tst_search(tst, SUC"foo") == NULL);
+    ok(23, tst_search(tst, SUC"te") == NULL);
+    ok_string(24, "Strange", tst_delete(tst, SUC"Strange"));
+    ok(25, tst_search(tst, SUC"Strange") == NULL);
+    ok_string(26, "t", tst_delete(tst, SUC"t"));
+    ok(27, tst_search(tst, SUC"t") == NULL);
+    ok_string(28, "testing", tst_search(tst, SUC"testing"));
+    ok_string(29, "foo", tst_search(tst, SUC"test"));
+    ok_string(30, "testing", tst_delete(tst, SUC"testing"));
+    ok_string(31, "foo", tst_search(tst, SUC"test"));
+    ok_string(32, "çhange", tst_delete(tst, SUC"çhange"));
+    ok_string(33, "foo", tst_delete(tst, SUC"test"));
     ok(34, tst_search(tst, NULL) == NULL);
     ok(35, tst_delete(tst, NULL) == NULL);
     tst_cleanup(tst);



More information about the inn-committers mailing list