netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: macb: Remove redundant assignment to w0
@ 2021-04-29 10:26 Jiapeng Chong
  2021-04-29 16:55 ` Nicolas Ferre
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-04-29 10:26 UTC (permalink / raw)
  To: nicolas.ferre
  Cc: claudiu.beznea, davem, kuba, linux, palmer, paul.walmsley,
	netdev, linux-kernel, linux-riscv, Jiapeng Chong

Variable w0 is set to zero but these values is not used as it is
overwritten later on, hence redundant assignment can be removed.

Cleans up the following clang-analyzer warning:

drivers/net/ethernet/cadence/macb_main.c:3265:3: warning: Value stored
to 'w0' is never read [clang-analyzer-deadcode.DeadStores].

drivers/net/ethernet/cadence/macb_main.c:3251:3: warning: Value stored
to 'w0' is never read [clang-analyzer-deadcode.DeadStores].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 0f6a6cb..741b2e3 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3248,7 +3248,6 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
 	/* ignore field if any masking set */
 	if (tp4sp_m->ip4src == 0xFFFFFFFF) {
 		/* 1st compare reg - IP source address */
-		w0 = 0;
 		w1 = 0;
 		w0 = tp4sp_v->ip4src;
 		w1 = GEM_BFINS(T2DISMSK, 1, w1); /* 32-bit compare */
@@ -3262,7 +3261,6 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
 	/* ignore field if any masking set */
 	if (tp4sp_m->ip4dst == 0xFFFFFFFF) {
 		/* 2nd compare reg - IP destination address */
-		w0 = 0;
 		w1 = 0;
 		w0 = tp4sp_v->ip4dst;
 		w1 = GEM_BFINS(T2DISMSK, 1, w1); /* 32-bit compare */
-- 
1.8.3.1


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

* Re: [PATCH] net: macb: Remove redundant assignment to w0
  2021-04-29 10:26 [PATCH] net: macb: Remove redundant assignment to w0 Jiapeng Chong
@ 2021-04-29 16:55 ` Nicolas Ferre
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Ferre @ 2021-04-29 16:55 UTC (permalink / raw)
  To: Jiapeng Chong, Rafal Ozieblo
  Cc: claudiu.beznea, davem, kuba, linux, palmer, paul.walmsley,
	netdev, linux-kernel, linux-riscv, Michal Simek

On 29/04/2021 at 12:26, Jiapeng Chong wrote:
> Variable w0 is set to zero but these values is not used as it is
> overwritten later on, hence redundant assignment can be removed.
> 
> Cleans up the following clang-analyzer warning:
> 
> drivers/net/ethernet/cadence/macb_main.c:3265:3: warning: Value stored
> to 'w0' is never read [clang-analyzer-deadcode.DeadStores].
> 
> drivers/net/ethernet/cadence/macb_main.c:3251:3: warning: Value stored
> to 'w0' is never read [clang-analyzer-deadcode.DeadStores].
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

NACK: there seems to be a massive bug in this code as I have the strong 
feeling that '=' must be replaces by '|=' in subsequent assignment of 
w0, W1... otherwise I don't understand the meaning of all this!

I don't know how RX filtering must be done in this controller neither 
how to test it so if nobody steps in to fix this, I'll probably have to 
do a patch based on datasheet only.

Please comment if you have a view on this.

Best regards,
   Nicolas

> ---
>   drivers/net/ethernet/cadence/macb_main.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 0f6a6cb..741b2e3 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3248,7 +3248,6 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
>          /* ignore field if any masking set */
>          if (tp4sp_m->ip4src == 0xFFFFFFFF) {
>                  /* 1st compare reg - IP source address */
> -               w0 = 0;
>                  w1 = 0;
>                  w0 = tp4sp_v->ip4src;
>                  w1 = GEM_BFINS(T2DISMSK, 1, w1); /* 32-bit compare */
> @@ -3262,7 +3261,6 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
>          /* ignore field if any masking set */
>          if (tp4sp_m->ip4dst == 0xFFFFFFFF) {
>                  /* 2nd compare reg - IP destination address */
> -               w0 = 0;
>                  w1 = 0;
>                  w0 = tp4sp_v->ip4dst;
>                  w1 = GEM_BFINS(T2DISMSK, 1, w1); /* 32-bit compare */
> --
> 1.8.3.1
> 


-- 
Nicolas Ferre

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

end of thread, other threads:[~2021-04-29 16:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 10:26 [PATCH] net: macb: Remove redundant assignment to w0 Jiapeng Chong
2021-04-29 16:55 ` Nicolas Ferre

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