lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b7bd47d4-c83d-7f2c-ef6c-a309bf101745@suse.com>
Date:   Mon, 23 Aug 2021 10:33:19 +0200
From:   Juergen Gross <jgross@...e.com>
To:     CGEL <cgel.zte@...il.com>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>
Cc:     Stefano Stabellini <sstabellini@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H . Peter Anvin" <hpa@...or.com>,
        xen-devel@...ts.xenproject.org, linux-kernel@...r.kernel.org,
        Jing Yangyang <jing.yangyang@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH linux-next] arch/x86/xen/time.c: fix bugon.cocci warnings

On 23.08.21 04:13, CGEL wrote:
> From: Jing Yangyang <jing.yangyang@....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@....com.cn>
> Signed-off-by: Jing Yangyang <jing.yangyang@....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

Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3092 bytes)

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ