Skip to contentSkip to conversation

ceph: use BUG() instead of BUG_ON(1)

PATCH Applied Arnd Bergmann 2 participants 2 messages Jan 16, 2017 Ceph common code (libceph)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: use BUG() instead of BUG_ON(1)

I ran into this compile warning, which is the result of BUG_ON(1) not always leading to the compiler treating the code path as unreachable:

include/linux/ceph/osdmap.h: In function 'ceph_can_shift_osds':
include/linux/ceph/osdmap.h:62:1: error: control reaches end of non-void function [-Werror=return-type]

Using BUG() here avoids the warning.

---
 include/linux/ceph/osdmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ceph/osdmap.h +1 -1
index 9a9041784dcf..412906609954 100644
@@ -57,7 +57,7 @@ static inline bool ceph_can_shift_osds(struct ceph_pg_pool_info *pool)
 	case CEPH_POOL_TYPE_EC:
 		return false;
 	default:
-		BUG_ON(1);
+		BUG();
 	}
 }
 
Signature · 1 line
2.9.0
maintainer Applied
#1 lore raw
Quoted 19 lines · Arnd Bergmann

I ran into this compile warning, which is the result of BUG_ON(1) not always leading to the compiler treating the code path as unreachable:

include/linux/ceph/osdmap.h: In function 'ceph_can_shift_osds':
include/linux/ceph/osdmap.h:62:1: error: control reaches end of non-void function [-Werror=return-type]

Using BUG() here avoids the warning.

---
 include/linux/ceph/osdmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ceph/osdmap.h +0 -0
index 9a9041784dcf..412906609954 100644

include/linux/ceph/osdmap.h static inline bool ceph_can_shift_osds(struct ceph_pg_pool_info *pool) · line 62

Quoted 7 lines
include/linux/ceph/osdmap.h +1 -1
@@ -57,7 +57,7 @@ static inline bool ceph_can_shift_osds(struct ceph_pg_pool_info *pool)
        case CEPH_POOL_TYPE_EC:
                return false;
        default:
-               BUG_ON(1);
+               BUG();
        }
 }

Applied.

Thanks,

Ilya