All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] s390:fix Coccinelle warnings
@ 2021-08-20  2:51 jing yangyang
  2021-08-23 18:07 ` Heiko Carstens
  0 siblings, 1 reply; 3+ messages in thread
From: jing yangyang @ 2021-08-20  2:51 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Vasily Gorbik, Christian Borntraeger, Vineeth Vijayan,
	Jiapeng Zhong, linux-s390, linux-kernel, jing yangyang,
	Zeal Robot

WARNING !A || A && B is equivalent to !A || B

This issue was detected with the help of Coccinelle.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: jing yangyang <jing.yangyang@zte.com.cn>
---
 arch/s390/include/asm/scsw.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/s390/include/asm/scsw.h b/arch/s390/include/asm/scsw.h
index a7c3ccf..754122d 100644
--- a/arch/s390/include/asm/scsw.h
+++ b/arch/s390/include/asm/scsw.h
@@ -691,9 +691,8 @@ 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.stctl & SCSW_STCTL_INTER_STATUS) ||
+		(scsw->tm.actl & SCSW_ACTL_SUSPENDED));
 }
 
 /**
-- 
1.8.3.1



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

* Re: [PATCH linux-next] s390:fix Coccinelle warnings
  2021-08-20  2:51 [PATCH linux-next] s390:fix Coccinelle warnings jing yangyang
@ 2021-08-23 18:07 ` Heiko Carstens
  2021-08-31  6:15   ` Vineeth Vijayan
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Carstens @ 2021-08-23 18:07 UTC (permalink / raw)
  To: jing yangyang
  Cc: Vasily Gorbik, Christian Borntraeger, Vineeth Vijayan,
	Jiapeng Zhong, linux-s390, linux-kernel, jing yangyang,
	Zeal Robot

On Thu, Aug 19, 2021 at 07:51:59PM -0700, jing yangyang wrote:
> WARNING !A || A && B is equivalent to !A || B
> 
> This issue was detected with the help of Coccinelle.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: jing yangyang <jing.yangyang@zte.com.cn>
> ---
>  arch/s390/include/asm/scsw.h | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/s390/include/asm/scsw.h b/arch/s390/include/asm/scsw.h
> index a7c3ccf..754122d 100644
> --- a/arch/s390/include/asm/scsw.h
> +++ b/arch/s390/include/asm/scsw.h
> @@ -691,9 +691,8 @@ 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.stctl & SCSW_STCTL_INTER_STATUS) ||
> +		(scsw->tm.actl & SCSW_ACTL_SUSPENDED));

This turns something unreadable into something else which is
unreadable. It's up to Vineeth to decide what to do with this.

However I'd prefer if this would be changed into something readable,
maybe as addon patch, like e.g.:

static inline bool scsw_tm_is_valid_pno(union scsw *scsw)
{
	if (scsw->tm.fctl == 0)
		return false;
	if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
		return false;
	if (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS))
		return false;
	if (scsw->tm.actl & SCSW_ACTL_SUSPENDED)
		return false;
	return true;
}

Chances are that the above is wrong... it's just to illustrate ;)

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

* Re: [PATCH linux-next] s390:fix Coccinelle warnings
  2021-08-23 18:07 ` Heiko Carstens
@ 2021-08-31  6:15   ` Vineeth Vijayan
  0 siblings, 0 replies; 3+ messages in thread
From: Vineeth Vijayan @ 2021-08-31  6:15 UTC (permalink / raw)
  To: Heiko Carstens, jing yangyang
  Cc: Vasily Gorbik, Christian Borntraeger, Jiapeng Zhong, linux-s390,
	linux-kernel, jing yangyang, Zeal Robot

I am a fan of Coccinelle fixes. But, here i think we need to do more 
work than just fixing it to
get rid of the warnings. I agree with Heiko. May be we should re-write 
this entire function and
make it readable.

Nack.


On 8/23/21 8:07 PM, Heiko Carstens wrote:
> On Thu, Aug 19, 2021 at 07:51:59PM -0700, jing yangyang wrote:
>> WARNING !A || A && B is equivalent to !A || B
>>
>> This issue was detected with the help of Coccinelle.
>>
>> Reported-by: Zeal Robot <zealci@zte.com.cn>
>> Signed-off-by: jing yangyang <jing.yangyang@zte.com.cn>
>> ---
>>   arch/s390/include/asm/scsw.h | 5 ++---
>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/s390/include/asm/scsw.h b/arch/s390/include/asm/scsw.h
>> index a7c3ccf..754122d 100644
>> --- a/arch/s390/include/asm/scsw.h
>> +++ b/arch/s390/include/asm/scsw.h
>> @@ -691,9 +691,8 @@ 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.stctl & SCSW_STCTL_INTER_STATUS) ||
>> +		(scsw->tm.actl & SCSW_ACTL_SUSPENDED));
> This turns something unreadable into something else which is
> unreadable. It's up to Vineeth to decide what to do with this.
>
> However I'd prefer if this would be changed into something readable,
> maybe as addon patch, like e.g.:
>
> static inline bool scsw_tm_is_valid_pno(union scsw *scsw)
> {
> 	if (scsw->tm.fctl == 0)
> 		return false;
> 	if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
> 		return false;
> 	if (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS))
> 		return false;
> 	if (scsw->tm.actl & SCSW_ACTL_SUSPENDED)
> 		return false;
> 	return true;
> }
>
> Chances are that the above is wrong... it's just to illustrate ;)

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

end of thread, other threads:[~2021-08-31  6:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20  2:51 [PATCH linux-next] s390:fix Coccinelle warnings jing yangyang
2021-08-23 18:07 ` Heiko Carstens
2021-08-31  6:15   ` Vineeth Vijayan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.