public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfsprogs: use abort() not ASSERT(0) for impossible switch case
@ 2014-08-21 17:32 Eric Sandeen
  2014-08-21 17:44 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Eric Sandeen @ 2014-08-21 17:32 UTC (permalink / raw)
  To: xfs-oss

The original reason for the expletive below has been lost
in the mists of time, but at any rate, ASSERT() goes away in
libxfs, and this leads static analysis checkers to believe that
XFS_BTNUM_MAX is possible, and that we might overflow an array
later when using it as an index.

We can shut this up and mark it as truly impossible with abort().

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/include/xfs_btree.h b/include/xfs_btree.h
index 2590d40..f4a1f61 100644
--- a/include/xfs_btree.h
+++ b/include/xfs_btree.h
@@ -69,7 +69,7 @@ do {    \
 	case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(bmbt, stat); break;	\
 	case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(ibt, stat); break;	\
 	case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(fibt, stat); break;	\
-	case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break;	\
+	case XFS_BTNUM_MAX: abort(); /* fucking gcc */ ; break;	\
 	}       \
 } while (0)
 
@@ -83,7 +83,7 @@ do {    \
 	case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_ADD(bmbt, stat, val); break; \
 	case XFS_BTNUM_INO: __XFS_BTREE_STATS_ADD(ibt, stat, val); break; \
 	case XFS_BTNUM_FINO: __XFS_BTREE_STATS_ADD(fibt, stat, val); break; \
-	case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break;	\
+	case XFS_BTNUM_MAX: abort(); /* fucking gcc */ ; break;	\
 	}       \
 } while (0)
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2014-08-21 22:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-21 17:32 [PATCH] xfsprogs: use abort() not ASSERT(0) for impossible switch case Eric Sandeen
2014-08-21 17:44 ` Christoph Hellwig
2014-08-21 17:45   ` Eric Sandeen
2014-08-21 18:27 ` [PATCH V2] xfsprogs: use ASSERT_ALWAYS " Eric Sandeen
2014-08-21 22:55   ` Dave Chinner
2014-08-21 22:50 ` [PATCH] xfsprogs: use abort() not ASSERT(0) " Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox