linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] btrfs-progs: Fix disable backtrace assert error
@ 2017-01-18  3:04 Qu Wenruo
  2017-01-18 11:38 ` Goldwyn Rodrigues
  0 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2017-01-18  3:04 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba, Goldwyn Rodrigues

Due to commit 00e769d04c2c83029d6c71(btrfs-progs: Correct value printed
by assertions/BUG_ON/WARN_ON), which changed the assert_trace()
parameter, the condition passed to assert/WARN_ON/BUG_ON are logical
notted for backtrace enabled and disabled case.

Such behavior makes us easier to pass value wrong, and in fact it did
cause us to pass wrong condition for ASSERT().

Instead of passing different conditions for ASSERT/WARN_ON/BUG_ON()
manually, this patch will use ASSERT() to implement the resting
ASSERT/WARN_ON/BUG(), so we don't need to pass 3 different conditions
but only one.

Also, move WARN_ON() out of the ifdef branch, as it's completely the
same for both branches.

Cc: Goldwyn Rodrigues <rgoldwyn@suse.de>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
Sorry for late update, being digging the dev-replace/scrub bug

v2:
  Keep ASSERT() outputing meaningful error string, use ASSERT() to
  implement BUG_ON() so only the abused BUG_ON() output is affected.
  Suggested by David.
v3:
  Update commit message, since we use ASSERT() instead of BUG_ON() as
  main assert function now.
---
 kerncompat.h | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/kerncompat.h b/kerncompat.h
index 19ed3fc0..fe23774e 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -291,18 +291,15 @@ static inline void assert_trace(const char *assertion, const char *filename,
 	abort();
 	exit(1);
 }
-
-#define BUG_ON(c) assert_trace(#c, __FILE__, __func__, __LINE__, (long)(c))
-#define WARN_ON(c) warning_trace(#c, __FILE__, __func__, __LINE__, (long)(c))
 #define	ASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (long)!(c))
-#define BUG() assert_trace(NULL, __FILE__, __func__, __LINE__, 1)
 #else
-#define BUG_ON(c) assert(!(c))
-#define WARN_ON(c) warning_trace(#c, __FILE__, __func__, __LINE__, (long)(c))
-#define ASSERT(c) assert(!(c))
-#define BUG() assert(0)
+#define ASSERT(c) assert(c)
 #endif
 
+#define BUG_ON(c) ASSERT(!(c))
+#define BUG() BUG_ON(1)
+#define WARN_ON(c) warning_trace(#c, __FILE__, __func__, __LINE__, (long)(c))
+
 #define container_of(ptr, type, member) ({                      \
         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
 	        (type *)( (char *)__mptr - offsetof(type,member) );})
-- 
2.11.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-19 12:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-18  3:04 [PATCH v3] btrfs-progs: Fix disable backtrace assert error Qu Wenruo
2017-01-18 11:38 ` Goldwyn Rodrigues
2017-01-19  0:27   ` Qu Wenruo
2017-01-19  3:42     ` Goldwyn Rodrigues
2017-01-19 12:08       ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).