From: Niels Möller Date: Sat, 3 Sep 2016 13:54:46 +0000 (+0200) Subject: Macro to convert string literals to unsigned. X-Git-Tag: nettle_3.3_release_20161001~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=330a14f65f900225babed296035aa9e18d4e2e7b;p=thirdparty%2Fnettle.git Macro to convert string literals to unsigned. --- diff --git a/ChangeLog b/ChangeLog index 3d6478ec..a3221403 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2016-09-03 Niels Möller + * 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. diff --git a/testsuite/testutils.h b/testsuite/testutils.h index 58786b65..2f74dc7c 100644 --- a/testsuite/testutils.h +++ b/testsuite/testutils.h @@ -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))