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] [thread-next>] [day] [month] [year] [list]
Message-ID: <9ab80e670fb341ddaba51a9cd78203fe@AcuMS.aculab.com>
Date:   Mon, 28 Mar 2022 12:15:49 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Haowen Bai' <baihaowen@...zu.com>,
        "hca@...ux.ibm.com" <hca@...ux.ibm.com>,
        "gor@...ux.ibm.com" <gor@...ux.ibm.com>,
        "agordeev@...ux.ibm.com" <agordeev@...ux.ibm.com>,
        "borntraeger@...ux.ibm.com" <borntraeger@...ux.ibm.com>,
        "svens@...ux.ibm.com" <svens@...ux.ibm.com>
CC:     "linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] s390: Simplify the calculation of variables

From: Haowen Bai
> Sent: 28 March 2022 03:36
> 
> Fix the following coccicheck warnings:
> ./arch/s390/include/asm/scsw.h:695:47-49: WARNING
>  !A || A && B is equivalent to !A || B
> 
> Signed-off-by: Haowen Bai <baihaowen@...zu.com>
> ---
>  arch/s390/include/asm/scsw.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/s390/include/asm/scsw.h b/arch/s390/include/asm/scsw.h
> index a7c3ccf..f2baac8 100644
> --- a/arch/s390/include/asm/scsw.h
> +++ b/arch/s390/include/asm/scsw.h
> @@ -692,8 +692,7 @@ static inline int scsw_tm_is_valid_pno(union scsw *scsw)
>  	return (scsw->tm.fctl != 0) &&
>  	       (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
>  	       (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) ||
> -		 ((scsw->tm.stctl & SCSW_STCTL_INTER_STATUS) &&
> -		  (scsw->tm.actl & SCSW_ACTL_SUSPENDED)));
> +	       (scsw->tm.actl & SCSW_ACTL_SUSPENDED))
>  }

I'd split that impenetrable boolean expression up.

I think this is equivalent:
	if (!scsw->tm.fctl)
		return 0;
	if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
		return 0;
	if (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS))
		return 1
	if (scsw->tm.actl & SCSW_ACTL_SUSPENDED)
		return 1;
	return 0;

The generated code could even be the same.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ