diff mbox series

[05/11] btrfs-progs: move BTRFS_DISABLE_BACKTRACE check in print_trace

Message ID ae1535f4741a70488bb30000dfe429fca624c536.1681938648.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: prep work for syncing files into kernel-shared | expand

Commit Message

Josef Bacik April 19, 2023, 9:13 p.m. UTC
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 <josef@toxicpanda.com>
---
 common/messages.c    |  3 ---
 include/kerncompat.h | 10 +++-------
 2 files changed, 3 insertions(+), 10 deletions(-)
diff mbox series

Patch

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);
 }