[dpdk-dev,2/3] net/cxgbe: remove unused variable usage

Message ID 20170124204859.8998-2-emmanuel.roullit@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Emmanuel Roullit Jan. 24, 2017, 8:48 p.m. UTC
  Found with clang static analysis:
drivers/net/cxgbe/sge.c:900:3: warning:
Value stored to 'in_use' is never read
        in_use += q->size;
        ^         ~~~~~~~

Fixes: c167acb61278 ("net/cxgbe: use I/O device memory read/write API")

Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
---
 drivers/net/cxgbe/sge.c | 4 ----
 1 file changed, 4 deletions(-)
  

Comments

Ferruh Yigit Jan. 25, 2017, 12:13 p.m. UTC | #1
On 1/24/2017 8:48 PM, Emmanuel Roullit wrote:
> Found with clang static analysis:
> drivers/net/cxgbe/sge.c:900:3: warning:
> Value stored to 'in_use' is never read
>         in_use += q->size;
>         ^         ~~~~~~~
> 
> Fixes: c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
> 
> Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
> ---
>  drivers/net/cxgbe/sge.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
> index fc03a0c26..42051ca01 100644
> --- a/drivers/net/cxgbe/sge.c
> +++ b/drivers/net/cxgbe/sge.c
> @@ -891,14 +891,10 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
>  	unsigned int flits, ndesc;
>  	unsigned char type = 0;
>  	int credits, hw_cidx = ntohs(q->stat->cidx);
> -	int in_use = q->pidx - hw_cidx + flits_to_desc(q->coalesce.flits);
>  
>  	/* use coal WR type 1 when no frags are present */
>  	type = (mbuf->nb_segs == 1) ? 1 : 0;
>  
> -	if (in_use < 0)
> -		in_use += q->size;

Intention can be "q->in_use" here. That change can be proper fix instead
of removing.

I will wait for maintainers comment to get the patch.

> -
>  	if (unlikely(type != q->coalesce.type && q->coalesce.idx))
>  		ship_tx_pkt_coalesce_wr(adap, txq);
>  
>
  
Rahul Lakkireddy Jan. 26, 2017, 4:41 a.m. UTC | #2
On Wednesday, January 01/25/17, 2017 at 17:43:57 +0530, Ferruh Yigit wrote:
> On 1/24/2017 8:48 PM, Emmanuel Roullit wrote:
> > Found with clang static analysis:
> > drivers/net/cxgbe/sge.c:900:3: warning:
> > Value stored to 'in_use' is never read
> >         in_use += q->size;
> >         ^         ~~~~~~~
> > 
> > Fixes: c167acb61278 ("net/cxgbe: use I/O device memory read/write API")

This fixes line seems to be wrong.  Should be:

Fixes: 4a01078b4fd1 ("cxgbe: add Tx support")

> > 
> > Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
> > ---
> >  drivers/net/cxgbe/sge.c | 4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
> > index fc03a0c26..42051ca01 100644
> > --- a/drivers/net/cxgbe/sge.c
> > +++ b/drivers/net/cxgbe/sge.c
> > @@ -891,14 +891,10 @@ static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
> >  	unsigned int flits, ndesc;
> >  	unsigned char type = 0;
> >  	int credits, hw_cidx = ntohs(q->stat->cidx);
> > -	int in_use = q->pidx - hw_cidx + flits_to_desc(q->coalesce.flits);
> >  
> >  	/* use coal WR type 1 when no frags are present */
> >  	type = (mbuf->nb_segs == 1) ? 1 : 0;
> >  
> > -	if (in_use < 0)
> > -		in_use += q->size;
> 
> Intention can be "q->in_use" here. That change can be proper fix instead
> of removing.
> 
> I will wait for maintainers comment to get the patch.
> 

in_use can be removed.  Also, Patch 2 and 3 can be merged.

> > -
> >  	if (unlikely(type != q->coalesce.type && q->coalesce.idx))
> >  		ship_tx_pkt_coalesce_wr(adap, txq);
> >  
> > 
> 

Thanks,
Rahul
  
Ferruh Yigit Jan. 26, 2017, 11:05 a.m. UTC | #3
On 1/26/2017 4:41 AM, Rahul Lakkireddy wrote:
> On Wednesday, January 01/25/17, 2017 at 17:43:57 +0530, Ferruh Yigit wrote:
>> On 1/24/2017 8:48 PM, Emmanuel Roullit wrote:
>>> Found with clang static analysis:
>>> drivers/net/cxgbe/sge.c:900:3: warning:
>>> Value stored to 'in_use' is never read
>>>         in_use += q->size;
>>>         ^         ~~~~~~~
>>>
>>> Fixes: c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
> 
> This fixes line seems to be wrong.  Should be:
> 

> 
>>>
>>> Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>

> Fixes: 4a01078b4fd1 ("cxgbe: add Tx support")
Cc: stable@dpdk.org

Acked-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>


Applied to dpdk-next-net/master, thanks.

(patch 2/3 and 3/3 merged)
  
Yuanhan Liu Feb. 14, 2017, 6:10 a.m. UTC | #4
On Thu, Jan 26, 2017 at 11:05:22AM +0000, Ferruh Yigit wrote:
> On 1/26/2017 4:41 AM, Rahul Lakkireddy wrote:
> > On Wednesday, January 01/25/17, 2017 at 17:43:57 +0530, Ferruh Yigit wrote:
> >> On 1/24/2017 8:48 PM, Emmanuel Roullit wrote:
> >>> Found with clang static analysis:
> >>> drivers/net/cxgbe/sge.c:900:3: warning:
> >>> Value stored to 'in_use' is never read
> >>>         in_use += q->size;
> >>>         ^         ~~~~~~~
> >>>
> >>> Fixes: c167acb61278 ("net/cxgbe: use I/O device memory read/write API")
> > 
> > This fixes line seems to be wrong.  Should be:
> > 
> 
> > 
> >>>
> >>> Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
> 
> > Fixes: 4a01078b4fd1 ("cxgbe: add Tx support")
> Cc: stable@dpdk.org

I doubt the necessary of picking it to a stable release: it doesn't fix
a real bug after all. Therefore, I will drop it for v16.11.1.

	--yliu 
> 
> Acked-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> 
> 
> Applied to dpdk-next-net/master, thanks.
> 
> (patch 2/3 and 3/3 merged)
  

Patch

diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index fc03a0c26..42051ca01 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -891,14 +891,10 @@  static inline int should_tx_packet_coalesce(struct sge_eth_txq *txq,
 	unsigned int flits, ndesc;
 	unsigned char type = 0;
 	int credits, hw_cidx = ntohs(q->stat->cidx);
-	int in_use = q->pidx - hw_cidx + flits_to_desc(q->coalesce.flits);
 
 	/* use coal WR type 1 when no frags are present */
 	type = (mbuf->nb_segs == 1) ? 1 : 0;
 
-	if (in_use < 0)
-		in_use += q->size;
-
 	if (unlikely(type != q->coalesce.type && q->coalesce.idx))
 		ship_tx_pkt_coalesce_wr(adap, txq);