]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Make free() a non inline function
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 20 Apr 2025 10:24:09 +0000 (12:24 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Apr 2025 09:50:32 +0000 (11:50 +0200)
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.

src/boot/util.c
src/boot/util.h
src/fundamental/iovec-util-fundamental.h

index 5dd111e7c5a053cb59f11036bb8996b31554f91b..a218ee2cc1fd6b54d54c6887f1898578bbcfaf3c 100644 (file)
 /* 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);
 
index e1d65770d6cf1a89031757a22615206a753e02af..323fb5163b14307a490af13fa58521a4200d1e1b 100644 (file)
 /* 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);
index 6b658c89587bb619272f1a8ff80a1177e64dc5a4..4c86197e6f7c49341d7ca50a9f27a4328054e12a 100644 (file)
@@ -17,7 +17,7 @@ struct iovec {
 };
 
 DISABLE_WARNING_REDUNDANT_DECLS;
-static inline void free(void *p);
+void free(void *p);
 REENABLE_WARNING;
 #endif