From 03e17cbe6e3085819d44e8861ce5452c6a158d76 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 12 Apr 2025 14:14:04 +0200 Subject: [PATCH] basic: Move assertion specific functions to assert-util.h Various functions in log.h are only used by asserts, and there's enough assertion related stuff in macro.h to justify a separate header which also makes it easier to avoid circular dependencies. Let's introduce assert-util.h and an accompanying fundamental header and move all the assertion related stuff over there. PROJECT_FILE is moved over to macro.h. --- src/basic/alloc-util.h | 1 + src/basic/argv-util.h | 1 + src/basic/assert-util.c | 65 +++++++++++++++++ src/basic/assert-util.h | 84 ++++++++++++++++++++++ src/basic/dlfcn-util.h | 1 + src/basic/errno-util.h | 1 + src/basic/log.c | 68 ------------------ src/basic/log.h | 24 ------- src/basic/macro.h | 73 +------------------ src/basic/meson.build | 1 + src/basic/signal-util.h | 1 + src/basic/stdio-util.h | 1 + src/boot/bcd.c | 1 + src/fundamental/assert-fundamental.h | 45 ++++++++++++ src/fundamental/iovec-util-fundamental.h | 2 + src/fundamental/macro-fundamental.h | 34 --------- src/fundamental/memory-util-fundamental.h | 1 + src/fundamental/sha256-fundamental.c | 1 + src/fundamental/string-util-fundamental.h | 1 + src/fuzz/fuzz.h | 1 + src/shared/fstab-util.h | 1 + src/shared/osc-context.h | 1 + src/shared/pretty-print.h | 1 + src/sysupdate/sysupdate-update-set-flags.c | 1 + src/test/test-dlopen.c | 1 + src/test/test-sizeof.c | 1 + src/udev/udevadm-hwdb.c | 1 + 27 files changed, 218 insertions(+), 196 deletions(-) create mode 100644 src/basic/assert-util.c create mode 100644 src/basic/assert-util.h create mode 100644 src/fundamental/assert-fundamental.h diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h index e589a94fd09..8bb3c421130 100644 --- a/src/basic/alloc-util.h +++ b/src/basic/alloc-util.h @@ -7,6 +7,7 @@ #include #include +#include "assert-util.h" #include "macro.h" #if HAS_FEATURE_MEMORY_SANITIZER diff --git a/src/basic/argv-util.h b/src/basic/argv-util.h index a20a951793a..deaa7c04e63 100644 --- a/src/basic/argv-util.h +++ b/src/basic/argv-util.h @@ -3,6 +3,7 @@ #include +#include "assert-util.h" #include "macro.h" extern int saved_argc; diff --git a/src/basic/assert-util.c b/src/basic/assert-util.c new file mode 100644 index 00000000000..f4cf97ad28b --- /dev/null +++ b/src/basic/assert-util.c @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include + +#include "assert-util.h" +#include "errno-util.h" +#include "log.h" + +static bool assert_return_is_critical = BUILD_MODE_DEVELOPER; + +/* Akin to glibc's __abort_msg; which is private and we hence cannot + * use here. */ +static char *log_abort_msg = NULL; + +void log_set_assert_return_is_critical(bool b) { + assert_return_is_critical = b; +} + +bool log_get_assert_return_is_critical(void) { + return assert_return_is_critical; +} + +static void log_assert( + int level, + const char *text, + const char *file, + int line, + const char *func, + const char *format) { + + static char buffer[LINE_MAX]; + + if (_likely_(LOG_PRI(level) > log_get_max_level())) + return; + + DISABLE_WARNING_FORMAT_NONLITERAL; + (void) snprintf(buffer, sizeof buffer, format, text, file, line, func); + REENABLE_WARNING; + + log_abort_msg = buffer; + + log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer); +} + +_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) { + log_assert(LOG_CRIT, text, file, line, func, + "Assertion '%s' failed at %s:%u, function %s(). Aborting."); + abort(); +} + +_noreturn_ void log_assert_failed_unreachable(const char *file, int line, const char *func) { + log_assert(LOG_CRIT, "Code should not be reached", file, line, func, + "%s at %s:%u, function %s(). Aborting. 💥"); + abort(); +} + +void log_assert_failed_return(const char *text, const char *file, int line, const char *func) { + + if (assert_return_is_critical) + log_assert_failed(text, file, line, func); + + PROTECT_ERRNO; + log_assert(LOG_DEBUG, text, file, line, func, + "Assertion '%s' failed at %s:%u, function %s(), ignoring."); +} diff --git a/src/basic/assert-util.h b/src/basic/assert-util.h new file mode 100644 index 00000000000..9383a6bb604 --- /dev/null +++ b/src/basic/assert-util.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include "assert-fundamental.h" +#include "macro.h" + +/* Logging for various assertions */ + +void log_set_assert_return_is_critical(bool b); +bool log_get_assert_return_is_critical(void) _pure_; + +_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func); +_noreturn_ void log_assert_failed_unreachable(const char *file, int line, const char *func); +void log_assert_failed_return(const char *text, const char *file, int line, const char *func); + +#ifdef __COVERITY__ + +/* Use special definitions of assertion macros in order to prevent + * false positives of ASSERT_SIDE_EFFECT on Coverity static analyzer + * for uses of assert_se() and assert_return(). + * + * These definitions make expression go through a (trivial) function + * call to ensure they are not discarded. Also use ! or !! to ensure + * the boolean expressions are seen as such. + * + * This technique has been described and recommended in: + * https://community.synopsys.com/s/question/0D534000046Yuzb/suppressing-assertsideeffect-for-functions-that-allow-for-sideeffects + */ + +extern void __coverity_panic__(void); + +static inline void __coverity_check__(int condition) { + if (!condition) + __coverity_panic__(); +} + +static inline int __coverity_check_and_return__(int condition) { + return condition; +} + +#define assert_message_se(expr, message) __coverity_check__(!!(expr)) + +#define assert_log(expr, message) __coverity_check_and_return__(!!(expr)) + +#else /* ! __COVERITY__ */ + +#define assert_message_se(expr, message) \ + do { \ + if (_unlikely_(!(expr))) \ + log_assert_failed(message, PROJECT_FILE, __LINE__, __func__); \ + } while (false) + +#define assert_log(expr, message) ((_likely_(expr)) \ + ? (true) \ + : (log_assert_failed_return(message, PROJECT_FILE, __LINE__, __func__), false)) + +#endif /* __COVERITY__ */ + +#define assert_se(expr) assert_message_se(expr, #expr) + +/* We override the glibc assert() here. */ +#undef assert +#ifdef NDEBUG +#define assert(expr) ({ if (!(expr)) __builtin_unreachable(); }) +#else +#define assert(expr) assert_message_se(expr, #expr) +#endif + +#define assert_not_reached() \ + log_assert_failed_unreachable(PROJECT_FILE, __LINE__, __func__) + +#define assert_return(expr, r) \ + do { \ + if (!assert_log(expr, #expr)) \ + return (r); \ + } while (false) + +#define assert_return_errno(expr, r, err) \ + do { \ + if (!assert_log(expr, #expr)) { \ + errno = err; \ + return (r); \ + } \ + } while (false) diff --git a/src/basic/dlfcn-util.h b/src/basic/dlfcn-util.h index 17c084ae733..e92e00b1e87 100644 --- a/src/basic/dlfcn-util.h +++ b/src/basic/dlfcn-util.h @@ -3,6 +3,7 @@ #include +#include "assert-util.h" #include "macro.h" static inline void* safe_dlclose(void *dl) { diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h index 02572e3bdcd..01b4d59e045 100644 --- a/src/basic/errno-util.h +++ b/src/basic/errno-util.h @@ -5,6 +5,7 @@ #include #include +#include "assert-util.h" #include "macro.h" /* strerror(3) says that glibc uses a maximum length of 1024 bytes. */ diff --git a/src/basic/log.c b/src/basic/log.c index 0c50cde0b41..3d2346f6869 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -78,11 +78,6 @@ static bool upgrade_syslog_to_journal = false; static bool always_reopen_console = false; static bool open_when_needed = false; static bool prohibit_ipc = false; -static bool assert_return_is_critical = BUILD_MODE_DEVELOPER; - -/* Akin to glibc's __abort_msg; which is private and we hence cannot - * use here. */ -static char *log_abort_msg = NULL; static thread_local const char *log_prefix = NULL; @@ -950,61 +945,6 @@ int log_object_internal( return r; } -static void log_assert( - int level, - const char *text, - const char *file, - int line, - const char *func, - const char *format) { - - static char buffer[LINE_MAX]; - - if (_likely_(LOG_PRI(level) > log_max_level)) - return; - - DISABLE_WARNING_FORMAT_NONLITERAL; - (void) snprintf(buffer, sizeof buffer, format, text, file, line, func); - REENABLE_WARNING; - - log_abort_msg = buffer; - - log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer); -} - -_noreturn_ void log_assert_failed( - const char *text, - const char *file, - int line, - const char *func) { - log_assert(LOG_CRIT, text, file, line, func, - "Assertion '%s' failed at %s:%u, function %s(). Aborting."); - abort(); -} - -_noreturn_ void log_assert_failed_unreachable( - const char *file, - int line, - const char *func) { - log_assert(LOG_CRIT, "Code should not be reached", file, line, func, - "%s at %s:%u, function %s(). Aborting. 💥"); - abort(); -} - -void log_assert_failed_return( - const char *text, - const char *file, - int line, - const char *func) { - - if (assert_return_is_critical) - log_assert_failed(text, file, line, func); - - PROTECT_ERRNO; - log_assert(LOG_DEBUG, text, file, line, func, - "Assertion '%s' failed at %s:%u, function %s(), ignoring."); -} - int log_oom_internal(int level, const char *file, int line, const char *func) { return log_internal(level, ENOMEM, file, line, func, "Out of memory."); } @@ -1318,14 +1258,6 @@ static int log_set_ratelimit_kmsg_from_string(const char *e) { return 0; } -void log_set_assert_return_is_critical(bool b) { - assert_return_is_critical = b; -} - -bool log_get_assert_return_is_critical(void) { - return assert_return_is_critical; -} - static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { /* diff --git a/src/basic/log.h b/src/basic/log.h index 34d2a5eb296..9759b28dc03 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -79,9 +79,6 @@ int log_show_tid_from_string(const char *e); * environment should not be called from library code — this is always a job * for the application itself. */ -assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1); -#define PROJECT_FILE (&__FILE__[STRLEN(RELATIVE_SOURCE_PATH) + 1]) - bool stderr_is_journal(void); int log_open(void); void log_close(void); @@ -185,24 +182,6 @@ int log_dump_internal( const char *func, char *buffer); -/* Logging for various assertions */ -_noreturn_ void log_assert_failed( - const char *text, - const char *file, - int line, - const char *func); - -_noreturn_ void log_assert_failed_unreachable( - const char *file, - int line, - const char *func); - -void log_assert_failed_return( - const char *text, - const char *file, - int line, - const char *func); - #define log_dispatch(level, error, buffer) \ log_dispatch_internal(level, error, PROJECT_FILE, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer) @@ -336,9 +315,6 @@ void log_set_open_when_needed(bool b); * stderr, the console or kmsg */ void log_set_prohibit_ipc(bool b); -void log_set_assert_return_is_critical(bool b); -bool log_get_assert_return_is_critical(void) _pure_; - int log_dup_console(void); int log_syntax_internal( diff --git a/src/basic/macro.h b/src/basic/macro.h index 2b3c02c3242..b1599633da5 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -42,6 +42,9 @@ #error "neither int nor long are four bytes long?!?" #endif +assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1); +#define PROJECT_FILE (&__FILE__[STRLEN(RELATIVE_SOURCE_PATH) + 1]) + static inline uint64_t u64_multiply_safe(uint64_t a, uint64_t b) { if (_unlikely_(a != 0 && b > (UINT64_MAX / a))) return 0; /* overflow */ @@ -103,76 +106,6 @@ static inline size_t GREEDY_ALLOC_ROUND_UP(size_t l) { (type*)( (char *)UNIQ_T(A, uniq) - offsetof(type, member) ); \ }) -#ifdef __COVERITY__ - -/* Use special definitions of assertion macros in order to prevent - * false positives of ASSERT_SIDE_EFFECT on Coverity static analyzer - * for uses of assert_se() and assert_return(). - * - * These definitions make expression go through a (trivial) function - * call to ensure they are not discarded. Also use ! or !! to ensure - * the boolean expressions are seen as such. - * - * This technique has been described and recommended in: - * https://community.synopsys.com/s/question/0D534000046Yuzb/suppressing-assertsideeffect-for-functions-that-allow-for-sideeffects - */ - -extern void __coverity_panic__(void); - -static inline void __coverity_check__(int condition) { - if (!condition) - __coverity_panic__(); -} - -static inline int __coverity_check_and_return__(int condition) { - return condition; -} - -#define assert_message_se(expr, message) __coverity_check__(!!(expr)) - -#define assert_log(expr, message) __coverity_check_and_return__(!!(expr)) - -#else /* ! __COVERITY__ */ - -#define assert_message_se(expr, message) \ - do { \ - if (_unlikely_(!(expr))) \ - log_assert_failed(message, PROJECT_FILE, __LINE__, __func__); \ - } while (false) - -#define assert_log(expr, message) ((_likely_(expr)) \ - ? (true) \ - : (log_assert_failed_return(message, PROJECT_FILE, __LINE__, __func__), false)) - -#endif /* __COVERITY__ */ - -#define assert_se(expr) assert_message_se(expr, #expr) - -/* We override the glibc assert() here. */ -#undef assert -#ifdef NDEBUG -#define assert(expr) ({ if (!(expr)) __builtin_unreachable(); }) -#else -#define assert(expr) assert_message_se(expr, #expr) -#endif - -#define assert_not_reached() \ - log_assert_failed_unreachable(PROJECT_FILE, __LINE__, __func__) - -#define assert_return(expr, r) \ - do { \ - if (!assert_log(expr, #expr)) \ - return (r); \ - } while (false) - -#define assert_return_errno(expr, r, err) \ - do { \ - if (!assert_log(expr, #expr)) { \ - errno = err; \ - return (r); \ - } \ - } while (false) - #define return_with_errno(r, err) \ do { \ errno = abs(err); \ diff --git a/src/basic/meson.build b/src/basic/meson.build index c3ca1537b51..9db77a95a64 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -7,6 +7,7 @@ basic_sources = files( 'architecture.c', 'argv-util.c', 'arphrd-util.c', + 'assert-util.c', 'audit-util.c', 'btrfs.c', 'build.c', diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h index dc2b9de1479..d64d5031243 100644 --- a/src/basic/signal-util.h +++ b/src/basic/signal-util.h @@ -3,6 +3,7 @@ #include +#include "assert-util.h" #include "macro.h" int reset_all_signal_handlers(void); diff --git a/src/basic/stdio-util.h b/src/basic/stdio-util.h index 0a2239d0225..bd5871821c4 100644 --- a/src/basic/stdio-util.h +++ b/src/basic/stdio-util.h @@ -6,6 +6,7 @@ #include #include +#include "assert-util.h" #include "macro.h" _printf_(3, 4) diff --git a/src/boot/bcd.c b/src/boot/bcd.c index 4533d479c14..9b5596b23aa 100644 --- a/src/boot/bcd.c +++ b/src/boot/bcd.c @@ -2,6 +2,7 @@ #include +#include "assert-fundamental.h" #include "bcd.h" #include "efi-string.h" diff --git a/src/fundamental/assert-fundamental.h b/src/fundamental/assert-fundamental.h new file mode 100644 index 00000000000..292656aa6b1 --- /dev/null +++ b/src/fundamental/assert-fundamental.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#if !SD_BOOT +# include +#endif + +#include "macro-fundamental.h" + +#if SD_BOOT + _noreturn_ void efi_assert(const char *expr, const char *file, unsigned line, const char *function); + + #ifdef NDEBUG + #define assert(expr) ({ if (!(expr)) __builtin_unreachable(); }) + #define assert_not_reached() __builtin_unreachable() + #else + #define assert(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __func__); }) + #define assert_not_reached() efi_assert("Code should not be reached", __FILE__, __LINE__, __func__) + #endif + #define assert_se(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __func__); }) +#endif + +/* This passes the argument through after (if asserts are enabled) checking that it is not null. */ +#define ASSERT_PTR(expr) _ASSERT_PTR(expr, UNIQ_T(_expr_, UNIQ), assert) +#define ASSERT_SE_PTR(expr) _ASSERT_PTR(expr, UNIQ_T(_expr_, UNIQ), assert_se) +#define _ASSERT_PTR(expr, var, check) \ + ({ \ + typeof(expr) var = (expr); \ + check(var); \ + var; \ + }) + +#define ASSERT_NONNEG(expr) \ + ({ \ + typeof(expr) _expr_ = (expr), _zero = 0; \ + assert(_expr_ >= _zero); \ + _expr_; \ + }) + +#define ASSERT_SE_NONNEG(expr) \ + ({ \ + typeof(expr) _expr_ = (expr), _zero = 0; \ + assert_se(_expr_ >= _zero); \ + _expr_; \ + }) diff --git a/src/fundamental/iovec-util-fundamental.h b/src/fundamental/iovec-util-fundamental.h index edd95fa4e9a..4214afea9a2 100644 --- a/src/fundamental/iovec-util-fundamental.h +++ b/src/fundamental/iovec-util-fundamental.h @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include "assert-fundamental.h" + #if SD_BOOT /* struct iovec is a POSIX userspace construct. Let's introduce it also in EFI mode, it's just so useful */ struct iovec { diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index ac18326a43a..585bacaf821 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -145,43 +145,9 @@ #define CONCATENATE(x, y) XCONCATENATE(x, y) #if SD_BOOT - _noreturn_ void efi_assert(const char *expr, const char *file, unsigned line, const char *function); - - #ifdef NDEBUG - #define assert(expr) ({ if (!(expr)) __builtin_unreachable(); }) - #define assert_not_reached() __builtin_unreachable() - #else - #define assert(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __func__); }) - #define assert_not_reached() efi_assert("Code should not be reached", __FILE__, __LINE__, __func__) - #endif #define static_assert _Static_assert - #define assert_se(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __func__); }) #endif -/* This passes the argument through after (if asserts are enabled) checking that it is not null. */ -#define ASSERT_PTR(expr) _ASSERT_PTR(expr, UNIQ_T(_expr_, UNIQ), assert) -#define ASSERT_SE_PTR(expr) _ASSERT_PTR(expr, UNIQ_T(_expr_, UNIQ), assert_se) -#define _ASSERT_PTR(expr, var, check) \ - ({ \ - typeof(expr) var = (expr); \ - check(var); \ - var; \ - }) - -#define ASSERT_NONNEG(expr) \ - ({ \ - typeof(expr) _expr_ = (expr), _zero = 0; \ - assert(_expr_ >= _zero); \ - _expr_; \ - }) - -#define ASSERT_SE_NONNEG(expr) \ - ({ \ - typeof(expr) _expr_ = (expr), _zero = 0; \ - assert_se(_expr_ >= _zero); \ - _expr_; \ - }) - #define assert_cc(expr) static_assert(expr, #expr) #define UNIQ_T(x, uniq) CONCATENATE(__unique_prefix_, CONCATENATE(x, uniq)) diff --git a/src/fundamental/memory-util-fundamental.h b/src/fundamental/memory-util-fundamental.h index f42d54f97a2..4b50714f5e1 100644 --- a/src/fundamental/memory-util-fundamental.h +++ b/src/fundamental/memory-util-fundamental.h @@ -9,6 +9,7 @@ # include #endif +#include "assert-fundamental.h" #include "macro-fundamental.h" #define memzero(x, l) \ diff --git a/src/fundamental/sha256-fundamental.c b/src/fundamental/sha256-fundamental.c index 03381835d6c..9f8b0106fe6 100644 --- a/src/fundamental/sha256-fundamental.c +++ b/src/fundamental/sha256-fundamental.c @@ -21,6 +21,7 @@ License along with the GNU C Library; if not, see . */ +#include "assert-fundamental.h" #include "macro-fundamental.h" #include "memory-util-fundamental.h" #include "sha256-fundamental.h" diff --git a/src/fundamental/string-util-fundamental.h b/src/fundamental/string-util-fundamental.h index ec3ad48706a..a9638b4d0e6 100644 --- a/src/fundamental/string-util-fundamental.h +++ b/src/fundamental/string-util-fundamental.h @@ -8,6 +8,7 @@ # include #endif +#include "assert-fundamental.h" #include "macro-fundamental.h" #if SD_BOOT diff --git a/src/fuzz/fuzz.h b/src/fuzz/fuzz.h index 123e88e8e93..6961fce7c1a 100644 --- a/src/fuzz/fuzz.h +++ b/src/fuzz/fuzz.h @@ -4,6 +4,7 @@ #include #include +#include "assert-util.h" #include "env-util.h" #include "fileio.h" diff --git a/src/shared/fstab-util.h b/src/shared/fstab-util.h index 3fc1440e197..8dd42700257 100644 --- a/src/shared/fstab-util.h +++ b/src/shared/fstab-util.h @@ -4,6 +4,7 @@ #include #include +#include "assert-util.h" #include "macro.h" bool fstab_enabled_full(int enabled); diff --git a/src/shared/osc-context.h b/src/shared/osc-context.h index 20c70b71831..6c9882c8944 100644 --- a/src/shared/osc-context.h +++ b/src/shared/osc-context.h @@ -3,6 +3,7 @@ #include "sd-id128.h" +#include "assert-util.h" #include "macro.h" int osc_context_open_boot(char **ret_seq); diff --git a/src/shared/pretty-print.h b/src/shared/pretty-print.h index fbfccb0a2e5..16966c3ab8c 100644 --- a/src/shared/pretty-print.h +++ b/src/shared/pretty-print.h @@ -2,6 +2,7 @@ #pragma once #include "ansi-color.h" +#include "assert-util.h" #include "glyph-util.h" #include "terminal-util.h" diff --git a/src/sysupdate/sysupdate-update-set-flags.c b/src/sysupdate/sysupdate-update-set-flags.c index e12c34a4362..ffed02d1f10 100644 --- a/src/sysupdate/sysupdate-update-set-flags.c +++ b/src/sysupdate/sysupdate-update-set-flags.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "ansi-color.h" +#include "assert-util.h" #include "glyph-util.h" #include "sysupdate-update-set-flags.h" #include "terminal-util.h" diff --git a/src/test/test-dlopen.c b/src/test/test-dlopen.c index 6704e936e7b..fd5bc32d5bf 100644 --- a/src/test/test-dlopen.c +++ b/src/test/test-dlopen.c @@ -3,6 +3,7 @@ #include #include +#include "assert-util.h" #include "macro.h" int main(int argc, char **argv) { diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c index ea0c58770ec..4e87f4ab740 100644 --- a/src/test/test-sizeof.c +++ b/src/test/test-sizeof.c @@ -11,6 +11,7 @@ #define __STDC_WANT_IEC_60559_TYPES_EXT__ #include +#include "assert-util.h" #include "time-util.h" /* Print information about various types. Useful when diagnosing diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index f306a4ffd6d..f4c3072b2e6 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -2,6 +2,7 @@ #include +#include "assert-util.h" #include "hwdb-util.h" #include "udevadm.h" -- 2.47.3