All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/net: appletalk/cops: remove redundant if statement and mask
@ 2018-12-22 16:58 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2018-12-22 16:58 UTC (permalink / raw)
  To: David S . Miller, netdev; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The two different assignments for pkt_len are actually the same and
so the if statement is redundant and can be removed.  Masking a u8
return value from inb() with 0xFF is also redundant and can also be
emoved.  Remove the redundant code.

Detected by CoverityScan, CID#1475639 ("Identical code for different
branches")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/appletalk/cops.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index bb49f6e40a19..64c74002fe8b 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -777,10 +777,7 @@ static void cops_rx(struct net_device *dev)
         }
 
         /* Get response length. */
-	if(lp->board==DAYNA)
-        	pkt_len = inb(ioaddr) & 0xFF;
-	else
-		pkt_len = inb(ioaddr) & 0x00FF;
+	pkt_len = inb(ioaddr);
         pkt_len |= (inb(ioaddr) << 8);
         /* Input IO code. */
         rsp_type=inb(ioaddr);
-- 
2.19.1


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

* [PATCH] drivers/net: appletalk/cops: remove redundant if statement and mask
@ 2018-12-22 16:58 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2018-12-22 16:58 UTC (permalink / raw)
  To: David S . Miller, netdev; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The two different assignments for pkt_len are actually the same and
so the if statement is redundant and can be removed.  Masking a u8
return value from inb() with 0xFF is also redundant and can also be
emoved.  Remove the redundant code.

Detected by CoverityScan, CID#1475639 ("Identical code for different
branches")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/appletalk/cops.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index bb49f6e40a19..64c74002fe8b 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -777,10 +777,7 @@ static void cops_rx(struct net_device *dev)
         }
 
         /* Get response length. */
-	if(lp->board=DAYNA)
-        	pkt_len = inb(ioaddr) & 0xFF;
-	else
-		pkt_len = inb(ioaddr) & 0x00FF;
+	pkt_len = inb(ioaddr);
         pkt_len |= (inb(ioaddr) << 8);
         /* Input IO code. */
         rsp_type=inb(ioaddr);
-- 
2.19.1

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

* Re: [PATCH] drivers/net: appletalk/cops: remove redundant if statement and mask
  2018-12-22 16:58 ` Colin King
@ 2018-12-24 18:08   ` David Miller
  -1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-12-24 18:08 UTC (permalink / raw)
  To: colin.king; +Cc: netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Sat, 22 Dec 2018 16:58:41 +0000

> @@ -777,10 +777,7 @@ static void cops_rx(struct net_device *dev)
>          }
>  
>          /* Get response length. */
> -	if(lp->board==DAYNA)
> -        	pkt_len = inb(ioaddr) & 0xFF;
> -	else
> -		pkt_len = inb(ioaddr) & 0x00FF;
> +	pkt_len = inb(ioaddr);

There are other instances of similar weird identical statements guarded
by the test on the board type being DAYNA.

For example, in cops_send_packet():

	if(lp->board == DAYNA)
               	outb(skb->len >> 8, ioaddr);
	else
		outb((skb->len >> 8)&0x0FF, ioaddr);

Could you scan the rest of the driver and deal with all of these
instances in one go?

Thank you!

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

* Re: [PATCH] drivers/net: appletalk/cops: remove redundant if statement and mask
@ 2018-12-24 18:08   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-12-24 18:08 UTC (permalink / raw)
  To: colin.king; +Cc: netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Sat, 22 Dec 2018 16:58:41 +0000

> @@ -777,10 +777,7 @@ static void cops_rx(struct net_device *dev)
>          }
>  
>          /* Get response length. */
> -	if(lp->board=DAYNA)
> -        	pkt_len = inb(ioaddr) & 0xFF;
> -	else
> -		pkt_len = inb(ioaddr) & 0x00FF;
> +	pkt_len = inb(ioaddr);

There are other instances of similar weird identical statements guarded
by the test on the board type being DAYNA.

For example, in cops_send_packet():

	if(lp->board = DAYNA)
               	outb(skb->len >> 8, ioaddr);
	else
		outb((skb->len >> 8)&0x0FF, ioaddr);

Could you scan the rest of the driver and deal with all of these
instances in one go?

Thank you!

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

* Re: [PATCH] drivers/net: appletalk/cops: remove redundant if statement and mask
  2018-12-24 18:08   ` David Miller
@ 2018-12-24 18:11     ` Colin Ian King
  -1 siblings, 0 replies; 6+ messages in thread
From: Colin Ian King @ 2018-12-24 18:11 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, kernel-janitors, linux-kernel

On 24/12/2018 18:08, David Miller wrote:
> From: Colin King <colin.king@canonical.com>
> Date: Sat, 22 Dec 2018 16:58:41 +0000
> 
>> @@ -777,10 +777,7 @@ static void cops_rx(struct net_device *dev)
>>          }
>>  
>>          /* Get response length. */
>> -	if(lp->board==DAYNA)
>> -        	pkt_len = inb(ioaddr) & 0xFF;
>> -	else
>> -		pkt_len = inb(ioaddr) & 0x00FF;
>> +	pkt_len = inb(ioaddr);
> 
> There are other instances of similar weird identical statements guarded
> by the test on the board type being DAYNA.
> 
> For example, in cops_send_packet():
> 
> 	if(lp->board == DAYNA)
>                	outb(skb->len >> 8, ioaddr);
> 	else
> 		outb((skb->len >> 8)&0x0FF, ioaddr);
> 
> Could you scan the rest of the driver and deal with all of these
> instances in one go?

Will do, probably in a day or so.
> 
> Thank you!
> 



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

* Re: [PATCH] drivers/net: appletalk/cops: remove redundant if statement and mask
@ 2018-12-24 18:11     ` Colin Ian King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin Ian King @ 2018-12-24 18:11 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, kernel-janitors, linux-kernel

On 24/12/2018 18:08, David Miller wrote:
> From: Colin King <colin.king@canonical.com>
> Date: Sat, 22 Dec 2018 16:58:41 +0000
> 
>> @@ -777,10 +777,7 @@ static void cops_rx(struct net_device *dev)
>>          }
>>  
>>          /* Get response length. */
>> -	if(lp->board=DAYNA)
>> -        	pkt_len = inb(ioaddr) & 0xFF;
>> -	else
>> -		pkt_len = inb(ioaddr) & 0x00FF;
>> +	pkt_len = inb(ioaddr);
> 
> There are other instances of similar weird identical statements guarded
> by the test on the board type being DAYNA.
> 
> For example, in cops_send_packet():
> 
> 	if(lp->board = DAYNA)
>                	outb(skb->len >> 8, ioaddr);
> 	else
> 		outb((skb->len >> 8)&0x0FF, ioaddr);
> 
> Could you scan the rest of the driver and deal with all of these
> instances in one go?

Will do, probably in a day or so.
> 
> Thank you!
> 

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

end of thread, other threads:[~2018-12-24 18:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-22 16:58 [PATCH] drivers/net: appletalk/cops: remove redundant if statement and mask Colin King
2018-12-22 16:58 ` Colin King
2018-12-24 18:08 ` David Miller
2018-12-24 18:08   ` David Miller
2018-12-24 18:11   ` Colin Ian King
2018-12-24 18:11     ` Colin Ian King

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.