Commit 330a14f6 authored by Niels Möller's avatar Niels Möller
Browse files

Macro to convert string literals to unsigned.

parent efac4e8f
2016-09-03 Niels Möller <nisse@lysator.liu.se> 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 * testsuite/rsa-encrypt-test.c (test_main): Fix pointer
signednesss warning. signednesss warning.
......
...@@ -267,10 +267,17 @@ void ...@@ -267,10 +267,17 @@ void
test_ecc_mul_h (unsigned curve, unsigned n, const mp_limb_t *p); test_ecc_mul_h (unsigned curve, unsigned n, const mp_limb_t *p);
#endif /* WITH_HOGWEED */ #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. */ /* LDATA needs to handle NUL characters. */
#define LLENGTH(x) (sizeof(x) - 1) #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 LDUP(x) strlen(x), strdup(x)
#define SHEX(x) (tstring_hex(x)) #define SHEX(x) (tstring_hex(x))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment