From: Daan De Meyer Date: Wed, 21 May 2025 09:59:16 +0000 (+0200) Subject: tests: Move implementation of DEFINE_HEX_PTR() into source file X-Git-Tag: v258-rc1~555^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f23910935d23254d3b6f580a5a37e0c6c2cc5a8;p=thirdparty%2Fsystemd.git tests: Move implementation of DEFINE_HEX_PTR() into source file Otherwise we have to add a hexdecoct.h include to tests.h which we want to avoid. --- diff --git a/src/shared/tests.c b/src/shared/tests.c index c2feab93355..66e1ae88cd6 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -20,6 +20,7 @@ #include "env-util.h" #include "fd-util.h" #include "fs-util.h" +#include "hexdecoct.h" #include "log.h" #include "mountpoint-util.h" #include "namespace-util.h" @@ -327,6 +328,10 @@ int enter_cgroup_root(char **ret_cgroup) { return enter_cgroup(ret_cgroup, false); } +int define_hex_ptr_internal(const char *hex, void **name, size_t *name_len) { + return unhexmem_full(hex, strlen_ptr(hex), false, name, name_len); +} + const char* ci_environment(void) { /* We return a string because we might want to provide multiple bits of information later on: not * just the general CI environment type, but also whether we're sanitizing or not, etc. The caller is diff --git a/src/shared/tests.h b/src/shared/tests.h index c9ebafdd83b..f339e25aef0 100644 --- a/src/shared/tests.h +++ b/src/shared/tests.h @@ -86,11 +86,13 @@ bool userns_has_single_user(void); #define CAN_MEMLOCK_SIZE (512 * 1024U) bool can_memlock(void); +int define_hex_ptr_internal(const char *hex, void **name, size_t *name_len); + /* Define void* buffer and size_t length variables from a hex string. */ #define DEFINE_HEX_PTR(name, hex) \ _cleanup_free_ void *name = NULL; \ size_t name##_len = 0; \ - assert_se(unhexmem_full(hex, strlen_ptr(hex), false, &name, &name##_len) >= 0); + assert_se(define_hex_ptr_internal(hex, &name, &name##_len) >= 0) /* Provide a convenient way to check if we're running in CI. */ const char* ci_environment(void);