linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390/qeth: remove useless if/else
@ 2020-11-08  6:34 xiakaixu1987
  2020-11-08 20:58 ` Joe Perches
  2020-11-09  8:05 ` Julian Wiedmann
  0 siblings, 2 replies; 3+ messages in thread
From: xiakaixu1987 @ 2020-11-08  6:34 UTC (permalink / raw)
  To: hca, gor, borntraeger; +Cc: linux-s390, linux-kernel, Kaixu Xia

From: Kaixu Xia <kaixuxia@tencent.com>

Fix the following coccinelle report:

./drivers/s390/net/qeth_l3_main.c:107:2-4: WARNING: possible condition with no effect (if == else)

Both branches are the same, so remove them.

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
 drivers/s390/net/qeth_l3_main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index b1c1d2510d55..264b6c782382 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -104,10 +104,7 @@ static bool qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card,
 		qeth_l3_convert_addr_to_bits(ipatoe->addr, ipatoe_bits,
 					  (ipatoe->proto == QETH_PROT_IPV4) ?
 					  4 : 16);
-		if (addr->proto == QETH_PROT_IPV4)
-			rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
-		else
-			rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
+		rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
 		if (rc)
 			break;
 	}
-- 
2.20.0


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

* Re: [PATCH] s390/qeth: remove useless if/else
  2020-11-08  6:34 [PATCH] s390/qeth: remove useless if/else xiakaixu1987
@ 2020-11-08 20:58 ` Joe Perches
  2020-11-09  8:05 ` Julian Wiedmann
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2020-11-08 20:58 UTC (permalink / raw)
  To: xiakaixu1987, hca, gor, borntraeger; +Cc: linux-s390, linux-kernel, Kaixu Xia

On Sun, 2020-11-08 at 14:34 +0800, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> Fix the following coccinelle report:
> 
> ./drivers/s390/net/qeth_l3_main.c:107:2-4: WARNING: possible condition with no effect (if == else)
> 
> Both branches are the same, so remove them.
[]
> diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
[]
> @@ -104,10 +104,7 @@ static bool qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card,
>  		qeth_l3_convert_addr_to_bits(ipatoe->addr, ipatoe_bits,
>  					  (ipatoe->proto == QETH_PROT_IPV4) ?
>  					  4 : 16);
> -		if (addr->proto == QETH_PROT_IPV4)
> -			rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
> -		else
> -			rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
> +		rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);

It's not always best to remove one branch.

Is this a copy/paste defect or is it useless?
Do you know which?
If you do, you should state this in the commit message.


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

* Re: [PATCH] s390/qeth: remove useless if/else
  2020-11-08  6:34 [PATCH] s390/qeth: remove useless if/else xiakaixu1987
  2020-11-08 20:58 ` Joe Perches
@ 2020-11-09  8:05 ` Julian Wiedmann
  1 sibling, 0 replies; 3+ messages in thread
From: Julian Wiedmann @ 2020-11-09  8:05 UTC (permalink / raw)
  To: xiakaixu1987, hca, gor, borntraeger; +Cc: linux-s390, linux-kernel, Kaixu Xia

On 08.11.20 08:34, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> Fix the following coccinelle report:
> 
> ./drivers/s390/net/qeth_l3_main.c:107:2-4: WARNING: possible condition with no effect (if == else)
> 
> Both branches are the same, so remove them.
> 

Indeed, missed that in commit
ab29c480b194 ("s390/qeth: replace deprecated simple_stroul()")

Applied, thanks!

> Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
> ---
>  drivers/s390/net/qeth_l3_main.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
> index b1c1d2510d55..264b6c782382 100644
> --- a/drivers/s390/net/qeth_l3_main.c
> +++ b/drivers/s390/net/qeth_l3_main.c
> @@ -104,10 +104,7 @@ static bool qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card,
>  		qeth_l3_convert_addr_to_bits(ipatoe->addr, ipatoe_bits,
>  					  (ipatoe->proto == QETH_PROT_IPV4) ?
>  					  4 : 16);
> -		if (addr->proto == QETH_PROT_IPV4)
> -			rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
> -		else
> -			rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
> +		rc = !memcmp(addr_bits, ipatoe_bits, ipatoe->mask_bits);
>  		if (rc)
>  			break;
>  	}
> 


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

end of thread, other threads:[~2020-11-09  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-08  6:34 [PATCH] s390/qeth: remove useless if/else xiakaixu1987
2020-11-08 20:58 ` Joe Perches
2020-11-09  8:05 ` Julian Wiedmann

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).