From 5a9b91576630f82ca72a932b5195654dbb04d67e Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 18 Aug 2022 13:43:19 +0200 Subject: tree-wide: Use __func__ in asserts clang puts the whole function signature in __PRETTY_FUNCTION__, which is a bit excessive for something that can already be figured out by using the line number. --- src/basic/macro.h | 6 +++--- src/fundamental/macro-fundamental.h | 6 +++--- src/journal/test-journal-interleaving.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/basic/macro.h b/src/basic/macro.h index a00d60824d..0d032866cf 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -175,12 +175,12 @@ static inline int __coverity_check_and_return__(int condition) { #define assert_message_se(expr, message) \ do { \ if (_unlikely_(!(expr))) \ - log_assert_failed(message, PROJECT_FILE, __LINE__, __PRETTY_FUNCTION__); \ + 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__, __PRETTY_FUNCTION__), false)) + : (log_assert_failed_return(message, PROJECT_FILE, __LINE__, __func__), false)) #endif /* __COVERITY__ */ @@ -195,7 +195,7 @@ static inline int __coverity_check_and_return__(int condition) { #endif #define assert_not_reached() \ - log_assert_failed_unreachable(PROJECT_FILE, __LINE__, __PRETTY_FUNCTION__) + log_assert_failed_unreachable(PROJECT_FILE, __LINE__, __func__) #define assert_return(expr, r) \ do { \ diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 71c6283e10..b2bc435bd3 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -74,11 +74,11 @@ #define assert(expr) #define assert_not_reached() __builtin_unreachable() #else - #define assert(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); }) - #define assert_not_reached() efi_assert("Code should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__) + #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__, __PRETTY_FUNCTION__); }) + #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. */ diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c index 379a0c8caf..67552de8fe 100644 --- a/src/journal/test-journal-interleaving.c +++ b/src/journal/test-journal-interleaving.c @@ -30,7 +30,7 @@ _noreturn_ static void log_assert_errno(const char *text, int error, const char do { \ int _r_ = (expr); \ if (_unlikely_(_r_ < 0)) \ - log_assert_errno(#expr, -_r_, PROJECT_FILE, __LINE__, __PRETTY_FUNCTION__); \ + log_assert_errno(#expr, -_r_, PROJECT_FILE, __LINE__, __func__); \ } while (false) static ManagedJournalFile *test_open(const char *name) { -- cgit v1.2.1