From 1c1a37c457e3684176eb6d18c2d66ccc64e99a59 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Thu, 25 Jan 2018 07:52:49 +0100 Subject: [PATCH] test/test-hexdecoct.c: Add include for musl_missin.h for strndupa(). shared/musl_missing.h: Rewrite strndupa() define to use x_ prefixed variables, so they won't shadow surronding variables of the same name. --- src/shared/musl_missing.h | 15 ++++++++------- src/test/test-hexdecoct.c | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/shared/musl_missing.h b/src/shared/musl_missing.h index 9b234556a..800dc18be 100644 --- a/src/shared/musl_missing.h +++ b/src/shared/musl_missing.h @@ -55,13 +55,14 @@ extern char *program_invocation_short_name; /* strndupa may already be defined in another compatibility header */ #if !defined(strndupa) -#define strndupa(src, n) \ - (__extension__ ({const char *in = (src); \ - size_t len = strnlen(in, (n)) + 1; \ - char *out = (char *) alloca(len); \ - out[len-1] = '\0'; \ - (char *) memcpy(out, in, len-1);}) \ - ) +#define strndupa(x_src, x_n) \ + (__extension__ ( { \ + const char* x_in = (x_src); \ + size_t x_len = strnlen(x_in, (x_n)) + 1; \ + char* x_out = (char *) alloca(x_len); \ + x_out[x_len-1] = '\0'; \ + (char *) memcpy(x_out, x_in, x_len-1); \ + } ) ) #endif /* See http://man7.org/linux/man-pages/man3/canonicalize_file_name.3.html */ diff --git a/src/test/test-hexdecoct.c b/src/test/test-hexdecoct.c index fcae427e7..3da1e6b16 100644 --- a/src/test/test-hexdecoct.c +++ b/src/test/test-hexdecoct.c @@ -22,6 +22,9 @@ #include "macro.h" #include "string-util.h" +/// Additional includes needed by elogind +#include "musl_missing.h" + static void test_hexchar(void) { assert_se(hexchar(0xa) == 'a'); assert_se(hexchar(0x0) == '0'); -- 2.30.2