]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: Move implementation of DEFINE_HEX_PTR() into source file
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 May 2025 09:59:16 +0000 (11:59 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 May 2025 11:59:18 +0000 (13:59 +0200)
Otherwise we have to add a hexdecoct.h include to tests.h which we
want to avoid.

src/shared/tests.c
src/shared/tests.h

index c2feab93355a54662e8b43e678800217d89348aa..66e1ae88cd64b4d222b1ad9ba65cf33f7b262ebd 100644 (file)
@@ -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
index c9ebafdd83bd7f4fc8999595ac2133af6ab6992f..f339e25aef04d45123fa64af39b49b99644a82d7 100644 (file)
@@ -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);