netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask
@ 2018-12-24 19:41 Colin King
  2018-12-24 22:49 ` David Miller
  2018-12-25  8:06 ` Sergei Shtylyov
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2018-12-24 19:41 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.

Similarly, the two different outb calls are identical as the mask
of 0xff on the second outb is redundant since a u8 is being written,
so the if statement is also redundant and can be also removed.

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

---

V2: Remove the if statement for the outb calls, thanks to David
Miller for spotting this.

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

diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index bb49f6e40a19..494663a18ce0 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);
@@ -892,10 +889,7 @@ static netdev_tx_t cops_send_packet(struct sk_buff *skb,
 
 	/* Output IO length. */
 	outb(skb->len, ioaddr);
-	if(lp->board == DAYNA)
-               	outb(skb->len >> 8, ioaddr);
-	else
-		outb((skb->len >> 8)&0x0FF, ioaddr);
+	outb(skb->len >> 8, ioaddr);
 
 	/* Output IO code. */
 	outb(LAP_WRITE, ioaddr);
-- 
2.19.1

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

* Re: [PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask
  2018-12-24 19:41 [PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask Colin King
@ 2018-12-24 22:49 ` David Miller
  2018-12-25  8:06 ` Sergei Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-12-24 22:49 UTC (permalink / raw)
  To: colin.king; +Cc: netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Mon, 24 Dec 2018 19:41:46 +0000

> 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.
> 
> Similarly, the two different outb calls are identical as the mask
> of 0xff on the second outb is redundant since a u8 is being written,
> so the if statement is also redundant and can be also removed.
> 
> Detected by CoverityScan, CID#1475639 ("Identical code for different
> branches")
> 
> ---
> 
> V2: Remove the if statement for the outb calls, thanks to David
> Miller for spotting this.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Colin, I almost didn't notice how the "---" there is in the wrong spot
and therefore was cutting out your changelog and signoff.

I fixed it up, but please be more careful in the future.

Thanks.

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

* Re: [PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask
  2018-12-24 19:41 [PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask Colin King
  2018-12-24 22:49 ` David Miller
@ 2018-12-25  8:06 ` Sergei Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2018-12-25  8:06 UTC (permalink / raw)
  To: Colin King, David S . Miller, netdev; +Cc: kernel-janitors, linux-kernel

On 24.12.2018 22:41, Colin King wrote:

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

    Removed. :-)

> Similarly, the two different outb calls are identical as the mask
> of 0xff on the second outb is redundant since a u8 is being written,
> so the if statement is also redundant and can be also removed.
> 
> Detected by CoverityScan, CID#1475639 ("Identical code for different
> branches")
> 
> ---
> 
> V2: Remove the if statement for the outb calls, thanks to David
> Miller for spotting this.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
[...]

MBR, Sergei

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

end of thread, other threads:[~2018-12-25  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24 19:41 [PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask Colin King
2018-12-24 22:49 ` David Miller
2018-12-25  8:06 ` Sergei Shtylyov

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