chiark / gitweb /
test/test-hexdecoct.c: Add include for musl_missin.h for strndupa().
authorSven Eden <yamakuzure@gmx.net>
Thu, 25 Jan 2018 06:52:49 +0000 (07:52 +0100)
committerSven Eden <yamakuzure@gmx.net>
Thu, 25 Jan 2018 22:04:04 +0000 (23:04 +0100)
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
src/test/test-hexdecoct.c

index 9b234556a7e137afffcf9868d15af6c564c31777..800dc18bef8ef6fbe482049e8868647b91ac6e15 100644 (file)
@@ -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 */
index fcae427e742f5f07337d731abf36dbf08549a5da..3da1e6b166c2bf418257886a7b418c05186a3824 100644 (file)
@@ -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');