Skip to content

Commit f794eaa

Browse files
committed
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.
1 parent d1461e5 commit f794eaa

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

util.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
/* Never try to read more than 16G into memory (and on 32bit 1G) */
1414
#define FILE_READ_MAX MIN(SIZE_MAX/4, UINT64_C(16)*1024U*1024U*1024U)
1515

16+
void free(void *p) {
17+
if (!p)
18+
return;
19+
20+
/* Debugging an invalid free requires trace logging to find the call site or a debugger attached. For
21+
* release builds it is not worth the bother to even warn when we cannot even print a call stack. */
22+
#ifdef EFI_DEBUG
23+
assert_se(BS->FreePool(p) == EFI_SUCCESS);
24+
#else
25+
(void) BS->FreePool(p);
26+
#endif
27+
}
28+
1629
void convert_efi_path(char16_t *path) {
1730
assert(path);
1831

util.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,9 @@
1414
/* This is provided by the linker. */
1515
extern uint8_t __executable_start[];
1616

17-
static inline void free(void *p) {
18-
if (!p)
19-
return;
20-
21-
/* Debugging an invalid free requires trace logging to find the call site or a debugger attached. For
22-
* release builds it is not worth the bother to even warn when we cannot even print a call stack. */
23-
#ifdef EFI_DEBUG
24-
assert_se(BS->FreePool(p) == EFI_SUCCESS);
25-
#else
26-
(void) BS->FreePool(p);
27-
#endif
28-
}
17+
DISABLE_WARNING_REDUNDANT_DECLS;
18+
void free(void *p);
19+
REENABLE_WARNING;
2920

3021
static inline void freep(void *p) {
3122
free(*(void **) p);

0 commit comments

Comments
 (0)