xfs
[Top] [All Lists]

[PATCH] xfsprogs: use abort() not ASSERT(0) for impossible switch case

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfsprogs: use abort() not ASSERT(0) for impossible switch case
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Thu, 21 Aug 2014 12:32:02 -0500
Delivered-to: xfs@xxxxxxxxxxx
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@xxxxxxxxxx>
---

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)
 

<Prev in Thread] Current Thread [Next in Thread>