Skip to contentSkip to conversation

Fix sparse false positives re BUG_ON(ptr)

PATCH New Alexey Dobriyan 1 participant 1 message Jul 13, 2007 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix sparse false positives re BUG_ON(ptr)

sparse now warns if one compares pointers with integers. However, there are false positives, like:

fs/filesystems.c:72:2: warning: Using plain integer as NULL pointer

Every time BUG_ON(ptr) is used, ptr is checked against integer zero. Avoid that and save ~70 false positives from allyesconfig run.

mentioned by Al.

---

 include/asm-generic/bug.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/bug.h +1 -1
@@ -28,7 +28,7 @@ struct bug_entry {
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
-#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
+#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
 #endif
 
 #ifndef HAVE_ARCH_WARN_ON