LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH linux-next] drivers/xen/events/events_base.c: fix bugon.cocci warnings
@ 2021-08-25  6:22 CGEL
  2021-08-25 12:53 ` Juergen Gross
  0 siblings, 1 reply; 2+ messages in thread
From: CGEL @ 2021-08-25  6:22 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Juergen Gross, Stefano Stabellini, Thomas Gleixner, Wei Liu,
	Jan Beulich, xen-devel, linux-kernel, Jing Yangyang, Zeal Robot

From: Jing Yangyang <jing.yangyang@zte.com.cn>

Use BUG_ON instead of a if condition followed by BUG.

Generated by: scripts/coccinelle/misc/bugon.cocci

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn>
---
 drivers/xen/events/events_base.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index a78704a..dd44019 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -818,8 +818,7 @@ static void xen_evtchn_close(evtchn_port_t port)
 	struct evtchn_close close;
 
 	close.port = port;
-	if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
-		BUG();
+	BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0);
 }
 
 /* Not called for lateeoi events. */
@@ -1270,9 +1269,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
 					      handle_percpu_irq, "ipi");
 
 		bind_ipi.vcpu = xen_vcpu_nr(cpu);
-		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
-						&bind_ipi) != 0)
-			BUG();
+		BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
+						&bind_ipi) != 0);
 		evtchn = bind_ipi.port;
 
 		ret = xen_irq_info_ipi_setup(cpu, irq, evtchn, ipi);
@@ -1983,9 +1981,8 @@ static void restore_cpu_virqs(unsigned int cpu)
 		/* Get a new binding from Xen. */
 		bind_virq.virq = virq;
 		bind_virq.vcpu = xen_vcpu_nr(cpu);
-		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
-						&bind_virq) != 0)
-			BUG();
+		BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
+						&bind_virq) != 0);
 		evtchn = bind_virq.port;
 
 		/* Record the new mapping. */
@@ -2009,9 +2006,8 @@ static void restore_cpu_ipis(unsigned int cpu)
 
 		/* Get a new binding from Xen. */
 		bind_ipi.vcpu = xen_vcpu_nr(cpu);
-		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
-						&bind_ipi) != 0)
-			BUG();
+		BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
+						&bind_ipi) != 0);
 		evtchn = bind_ipi.port;
 
 		/* Record the new mapping. */
@@ -2063,8 +2059,7 @@ void xen_poll_irq_timeout(int irq, u64 timeout)
 		poll.timeout = timeout;
 		set_xen_guest_handle(poll.ports, &evtchn);
 
-		if (HYPERVISOR_sched_op(SCHEDOP_poll, &poll) != 0)
-			BUG();
+		BUG_ON(HYPERVISOR_sched_op(SCHEDOP_poll, &poll) != 0);
 	}
 }
 EXPORT_SYMBOL(xen_poll_irq_timeout);
-- 
1.8.3.1



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

* Re: [PATCH linux-next] drivers/xen/events/events_base.c: fix bugon.cocci warnings
  2021-08-25  6:22 [PATCH linux-next] drivers/xen/events/events_base.c: fix bugon.cocci warnings CGEL
@ 2021-08-25 12:53 ` Juergen Gross
  0 siblings, 0 replies; 2+ messages in thread
From: Juergen Gross @ 2021-08-25 12:53 UTC (permalink / raw)
  To: CGEL, Boris Ostrovsky
  Cc: Stefano Stabellini, Thomas Gleixner, Wei Liu, Jan Beulich,
	xen-devel, linux-kernel, Jing Yangyang, Zeal Robot


[-- Attachment #1.1.1: Type: text/plain, Size: 2806 bytes --]

On 25.08.21 08:22, CGEL wrote:
> From: Jing Yangyang <jing.yangyang@zte.com.cn>
> 
> Use BUG_ON instead of a if condition followed by BUG.
> 
> Generated by: scripts/coccinelle/misc/bugon.cocci
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn>

I already gave you feedback for another patch asking you to adjust
the continuation line indentations.

Same here.


Juergen

> ---
>   drivers/xen/events/events_base.c | 21 ++++++++-------------
>   1 file changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
> index a78704a..dd44019 100644
> --- a/drivers/xen/events/events_base.c
> +++ b/drivers/xen/events/events_base.c
> @@ -818,8 +818,7 @@ static void xen_evtchn_close(evtchn_port_t port)
>   	struct evtchn_close close;
>   
>   	close.port = port;
> -	if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
> -		BUG();
> +	BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0);
>   }
>   
>   /* Not called for lateeoi events. */
> @@ -1270,9 +1269,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
>   					      handle_percpu_irq, "ipi");
>   
>   		bind_ipi.vcpu = xen_vcpu_nr(cpu);
> -		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
> -						&bind_ipi) != 0)
> -			BUG();
> +		BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
> +						&bind_ipi) != 0);
>   		evtchn = bind_ipi.port;
>   
>   		ret = xen_irq_info_ipi_setup(cpu, irq, evtchn, ipi);
> @@ -1983,9 +1981,8 @@ static void restore_cpu_virqs(unsigned int cpu)
>   		/* Get a new binding from Xen. */
>   		bind_virq.virq = virq;
>   		bind_virq.vcpu = xen_vcpu_nr(cpu);
> -		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
> -						&bind_virq) != 0)
> -			BUG();
> +		BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
> +						&bind_virq) != 0);
>   		evtchn = bind_virq.port;
>   
>   		/* Record the new mapping. */
> @@ -2009,9 +2006,8 @@ static void restore_cpu_ipis(unsigned int cpu)
>   
>   		/* Get a new binding from Xen. */
>   		bind_ipi.vcpu = xen_vcpu_nr(cpu);
> -		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
> -						&bind_ipi) != 0)
> -			BUG();
> +		BUG_ON(HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
> +						&bind_ipi) != 0);
>   		evtchn = bind_ipi.port;
>   
>   		/* Record the new mapping. */
> @@ -2063,8 +2059,7 @@ void xen_poll_irq_timeout(int irq, u64 timeout)
>   		poll.timeout = timeout;
>   		set_xen_guest_handle(poll.ports, &evtchn);
>   
> -		if (HYPERVISOR_sched_op(SCHEDOP_poll, &poll) != 0)
> -			BUG();
> +		BUG_ON(HYPERVISOR_sched_op(SCHEDOP_poll, &poll) != 0);
>   	}
>   }
>   EXPORT_SYMBOL(xen_poll_irq_timeout);
> 


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

end of thread, other threads:[~2021-08-25 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25  6:22 [PATCH linux-next] drivers/xen/events/events_base.c: fix bugon.cocci warnings CGEL
2021-08-25 12:53 ` Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).