diff mbox series

[3/5] btrfs: add debug build only WARN

Message ID 6f48b375412c74e9e41422068f9777804b522169.1744794336.git.dsterba@suse.com (mailing list archive)
State New
Headers show
Series Assertion and debugging helpers | expand

Commit Message

David Sterba April 16, 2025, 9:08 a.m. UTC
Add conditional WARN() wrapper that's enabled only in debug build. It
should be used for unexpected condtions that should be noisy.  Use it
instead of ASSERT(0). As it will not lead to BUG() make sure that
continuing is still possible, e.g. the error is handled anyway.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/messages.h | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 8cca9d834b274d..31f9a2597a1c96 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -204,6 +204,13 @@  static inline void btrfs_assertfail_verbose(const char *str_expr,
 #define VASSERT(expr, fmt, ...)		(void)(expr)
 #endif
 
+#ifdef CONFIG_BTRFS_DEBUG
+/* Verbose warning only under debug build. */
+#define DEBUG_WARN(args...)	WARN(1, KERN_ERR args)
+#else
+#define DEBUG_WARN(...)		do {} while(0)
+#endif
+
 __printf(5, 6)
 __cold
 void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,