From e051593934e432f77132741c39bf811ca29f9a47 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 19 Apr 2023 17:13:47 -0400 Subject: [PATCH] btrfs-progs: move BTRFS_DISABLE_BACKTRACE check in print_trace Everybody who calls print_trace wraps it around this check, move the check instead to print_trace and remove the check from all the callers. Signed-off-by: Josef Bacik Signed-off-by: David Sterba --- common/messages.c | 3 --- include/kerncompat.h | 10 +++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/common/messages.c b/common/messages.c index 2d9d55c0..4ef7a34a 100644 --- a/common/messages.c +++ b/common/messages.c @@ -96,10 +96,7 @@ void internal_error(const char *fmt, ...) vfprintf(stderr, fmt, vargs); va_end(vargs); fputc('\n', stderr); - -#ifndef BTRFS_DISABLE_BACKTRACE print_trace(); -#endif } static bool should_print(int level) diff --git a/include/kerncompat.h b/include/kerncompat.h index 62b6a357..cb2a9400 100644 --- a/include/kerncompat.h +++ b/include/kerncompat.h @@ -94,17 +94,17 @@ #define BUILD_ASSERT(x) #endif -#ifndef BTRFS_DISABLE_BACKTRACE -#define MAX_BACKTRACE 16 static inline void print_trace(void) { +#ifndef BTRFS_DISABLE_BACKTRACE +#define MAX_BACKTRACE 16 void *array[MAX_BACKTRACE]; int size; size = backtrace(array, MAX_BACKTRACE); backtrace_symbols_fd(array, size, 2); -} #endif +} static inline void warning_trace(const char *assertion, const char *filename, const char *func, unsigned line, long val) @@ -114,9 +114,7 @@ static inline void warning_trace(const char *assertion, const char *filename, fprintf(stderr, "%s:%u: %s: Warning: assertion `%s` failed, value %ld\n", filename, line, func, assertion, val); -#ifndef BTRFS_DISABLE_BACKTRACE print_trace(); -#endif } static inline void bugon_trace(const char *assertion, const char *filename, @@ -127,9 +125,7 @@ static inline void bugon_trace(const char *assertion, const char *filename, fprintf(stderr, "%s:%u: %s: BUG_ON `%s` triggered, value %ld\n", filename, line, func, assertion, val); -#ifndef BTRFS_DISABLE_BACKTRACE print_trace(); -#endif abort(); exit(1); }