]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Macro to convert string literals to unsigned.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 3 Sep 2016 13:54:46 +0000 (15:54 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 3 Sep 2016 13:54:46 +0000 (15:54 +0200)
ChangeLog
testsuite/testutils.h

index 3d6478ecb3d655c3c09848e2e6d6c63bb5d9fb95..a322140376d3d5396a8391e4436d06b49b386bbf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2016-09-03  Niels Möller  <nisse@lysator.liu.se>
 
+       * testsuite/testutils.h (US): New macro, for unsigned string
+       literals.
+       (LDATA): Use the US macro, to eliminate pointer signedness
+       warnings.
+
        * testsuite/rsa-encrypt-test.c (test_main): Fix pointer
        signednesss warning.
 
index 58786b6553c37892f41d7dc1d7a52afa663cd6cb..2f74dc7c3e5f978fb2717b7282d3372e82c01ca9 100644 (file)
@@ -267,10 +267,17 @@ void
 test_ecc_mul_h (unsigned curve, unsigned n, const mp_limb_t *p);
 
 #endif /* WITH_HOGWEED */
+
+/* String literal of type unsigned char. The GNUC version is safer. */
+#if __GNUC__
+#define US(s) ({ static const unsigned char us_s[] = s; us_s; })
+#else
+#define US(s) ((const uint8_t *) (s))
+#endif
   
 /* LDATA needs to handle NUL characters. */
 #define LLENGTH(x) (sizeof(x) - 1)
-#define LDATA(x) LLENGTH(x), x
+#define LDATA(x) LLENGTH(x), US(x)
 #define LDUP(x) strlen(x), strdup(x)
 
 #define SHEX(x) (tstring_hex(x))