From: Daan De Meyer Date: Sun, 20 Apr 2025 10:24:09 +0000 (+0200) Subject: boot: Make free() a non inline function X-Git-Tag: v258-rc1~755^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed2506d1d077431713308311bafedfc4170cd19a;p=thirdparty%2Fsystemd.git boot: Make free() a non inline function The static inline declaration in iovec-fundamental.h causes static analyze tooling warnings (clang-tidy). Let's get around it by making free() non-inline. LTO will make sure it's still inlined properly. --- diff --git a/src/boot/util.c b/src/boot/util.c index 5dd111e7c5a..a218ee2cc1f 100644 --- a/src/boot/util.c +++ b/src/boot/util.c @@ -13,6 +13,19 @@ /* Never try to read more than 16G into memory (and on 32bit 1G) */ #define FILE_READ_MAX MIN(SIZE_MAX/4, UINT64_C(16)*1024U*1024U*1024U) +void free(void *p) { + if (!p) + return; + + /* Debugging an invalid free requires trace logging to find the call site or a debugger attached. For + * release builds it is not worth the bother to even warn when we cannot even print a call stack. */ +#ifdef EFI_DEBUG + assert_se(BS->FreePool(p) == EFI_SUCCESS); +#else + (void) BS->FreePool(p); +#endif +} + void convert_efi_path(char16_t *path) { assert(path); diff --git a/src/boot/util.h b/src/boot/util.h index e1d65770d6c..323fb5163b1 100644 --- a/src/boot/util.h +++ b/src/boot/util.h @@ -14,18 +14,9 @@ /* This is provided by the linker. */ extern uint8_t __executable_start[]; -static inline void free(void *p) { - if (!p) - return; - - /* Debugging an invalid free requires trace logging to find the call site or a debugger attached. For - * release builds it is not worth the bother to even warn when we cannot even print a call stack. */ -#ifdef EFI_DEBUG - assert_se(BS->FreePool(p) == EFI_SUCCESS); -#else - (void) BS->FreePool(p); -#endif -} +DISABLE_WARNING_REDUNDANT_DECLS; +void free(void *p); +REENABLE_WARNING; static inline void freep(void *p) { free(*(void **) p); diff --git a/src/fundamental/iovec-util-fundamental.h b/src/fundamental/iovec-util-fundamental.h index 6b658c89587..4c86197e6f7 100644 --- a/src/fundamental/iovec-util-fundamental.h +++ b/src/fundamental/iovec-util-fundamental.h @@ -17,7 +17,7 @@ struct iovec { }; DISABLE_WARNING_REDUNDANT_DECLS; -static inline void free(void *p); +void free(void *p); REENABLE_WARNING; #endif