Re: [PATCH] s390: Simplify the calculation of variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 28, 2022 at 12:15:49PM +0000, David Laight wrote:
> 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@xxxxxxxxx>
> > ---
> >  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.

Yes, we had the very same discussion here:
https://lore.kernel.org/linux-s390/20210820025159.11914-1-jing.yangyang@xxxxxxxxxx/

Where the outcome also was that it doesn't make sense to replace one
unreadable version with another unreadable version just to get rid of
a warning.

Haowen, could you please resend with a proper readable version, or
alternatively, Vineeth, could you address this please, so this doesn't
come up again?

Thanks!



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux