linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: CGEL <cgel.zte@gmail.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
	Jing Yangyang <jing.yangyang@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] arch/x86/xen/time.c: fix bugon.cocci warnings
Date: Mon, 23 Aug 2021 10:33:19 +0200	[thread overview]
Message-ID: <b7bd47d4-c83d-7f2c-ef6c-a309bf101745@suse.com> (raw)
In-Reply-To: <20210823021353.44391-1-jing.yangyang@zte.com.cn>


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

On 23.08.21 04:13, 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>
> ---
>   arch/x86/xen/time.c | 20 ++++++++------------
>   1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
> index d9c945e..6e29b69 100644
> --- a/arch/x86/xen/time.c
> +++ b/arch/x86/xen/time.c
> @@ -210,8 +210,7 @@ static int xen_timerop_set_next_event(unsigned long delta,
>   {
>   	WARN_ON(!clockevent_state_oneshot(evt));
>   
> -	if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0)
> -		BUG();
> +	BUG_ON(HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0);
>   
>   	/* We may have missed the deadline, but there's no real way of
>   	   knowing for sure.  If the event was in the past, then we'll
> @@ -241,11 +240,10 @@ static int xen_vcpuop_shutdown(struct clock_event_device *evt)
>   {
>   	int cpu = smp_processor_id();
>   
> -	if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, xen_vcpu_nr(cpu),
> +	BUG_ON(HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, xen_vcpu_nr(cpu),
>   			       NULL) ||

Please adjust the alignment of the continuation line (i.e. insert 2
blanks). Same below.

Even better would be to avoid the repeated "xen_vcpu_nr(cpu)" by
using "int vcpu = xen_vcpu_nr(smp_processor_id());" leading to the
possibility to not need the continuation lines at all.

> -	    HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu),
> -			       NULL))
> -		BUG();
> +		HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu),
> +			       NULL));
>   
>   	return 0;
>   }
> @@ -254,9 +252,8 @@ static int xen_vcpuop_set_oneshot(struct clock_event_device *evt)
>   {
>   	int cpu = smp_processor_id();
>   
> -	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu),
> -			       NULL))
> -		BUG();
> +	BUG_ON(HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu),
> +			       NULL));

See above.

>   
>   	return 0;
>   }
> @@ -373,9 +370,8 @@ void xen_timer_resume(void)
>   		return;
>   
>   	for_each_online_cpu(cpu) {
> -		if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer,
> -				       xen_vcpu_nr(cpu), NULL))
> -			BUG();
> +		BUG_ON(HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer,
> +				       xen_vcpu_nr(cpu), NULL));

See above.


Juergen

[-- 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 --]

      reply	other threads:[~2021-08-23  8:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  2:13 [PATCH linux-next] arch/x86/xen/time.c: fix bugon.cocci warnings CGEL
2021-08-23  8:33 ` Juergen Gross [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7bd47d4-c83d-7f2c-ef6c-a309bf101745@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=cgel.zte@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jing.yangyang@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=zealci@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).