Skip to contentSkip to conversation

xen/evtchn: replace if (cond) BUG() with BUG_ON()

PATCH Superseded Jiapeng Chong 2 participants 2 messages Mar 17, 2021 Xen hypervisor interface

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/evtchn: replace if (cond) BUG() with BUG_ON()

Fix the following coccicheck warnings:

./drivers/xen/evtchn.c:412:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

---
 drivers/xen/evtchn.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/xen/evtchn.c +1 -2
index c99415a..b1c59bc 100644
@@ -408,8 +408,7 @@ static int evtchn_bind_to_user(struct per_user_data *u, evtchn_port_t port)
 err:
 	/* bind failed, should close the port now */
 	close.port = port;
-	if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
-		BUG();
+	BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0);
 	del_evtchn(u, evtchn);
 	return rc;
 }
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 16 lines · Jiapeng Chong

Fix the following coccicheck warnings:

./drivers/xen/evtchn.c:412:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

---
 drivers/xen/evtchn.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/xen/evtchn.c +0 -0
index c99415a..b1c59bc 100644

drivers/xen/evtchn.c static int evtchn_bind_to_user(struct per_user_data *u, evtchn_port_t port) · line 411

Quoted 6 lines
drivers/xen/evtchn.c +1 -2
@@ -408,8 +408,7 @@ static int evtchn_bind_to_user(struct per_user_data *u, evtchn_port_t port)
 err:
 	/* bind failed, should close the port now */
 	close.port = port;
-	if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
-		BUG();
+	BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0);

Is it actually worth doing a BUG() here at all? Seems to me WARN_ON_ONCE() should be sufficient.

-boris

Quoted 3 lines
drivers/xen/evtchn.c +0 -0
 	del_evtchn(u, evtchn);
 	return rc;
 }