diff mbox

iwl4965: fix 'phys_addr' may be used uninitialized

Message ID 20130215095221.GE4392@redhat.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Stanislaw Gruszka Feb. 15, 2013, 9:52 a.m. UTC
This should fix:

drivers/net/wireless/iwlegacy/4965-mac.c:1847:33: warning: 'phys_addr' may be used uninitialized in this function [-Wmaybe-uninitialized]

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/iwlegacy/4965-mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John W. Linville Feb. 15, 2013, 7:26 p.m. UTC | #1
I still get the warning when building wireless-next on my F17 box
with this patch applied...

On Fri, Feb 15, 2013 at 10:52:21AM +0100, Stanislaw Gruszka wrote:
> This should fix:
> 
> drivers/net/wireless/iwlegacy/4965-mac.c:1847:33: warning: 'phys_addr' may be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/iwlegacy/4965-mac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
> index 7941eb3..d2ab1cf 100644
> --- a/drivers/net/wireless/iwlegacy/4965-mac.c
> +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
> @@ -1843,7 +1843,7 @@ il4965_tx_skb(struct il_priv *il,
>  	il->ops->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0);
>  	dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
>  	dma_unmap_len_set(out_meta, len, firstlen);
> -	if (secondlen)
> +	if (secondlen > 0)
>  		il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen,
>  					       0, 0);
>  
> -- 
> 1.7.11.7
> 
>
Stanislaw Gruszka Feb. 18, 2013, 8:40 a.m. UTC | #2
On Fri, Feb 15, 2013 at 02:26:27PM -0500, John W. Linville wrote:
> I still get the warning when building wireless-next on my F17 box
> with this patch applied...

I have no warning of F17 with:

gcc-4.7.2-2.fc17.x86_64

perhaps you use i686 or kernel config is different.

This warning must be a false positive. The code looks like below:

        secondlen = skb->len - hdr_len;
        if (secondlen > 0) {
                phys_addr =
                    pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen,
                                   PCI_DMA_TODEVICE);
                if (unlikely(pci_dma_mapping_error(il->pci_dev, phys_addr)))
                        goto drop_unlock;
        }
	/* */
        if (secondlen > 0)
                il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen,
                                               0, 0);

and there are no other places where phys_addr is used.

I just realized that secondlen is u16, so there is no difference between
"if (secondlen)" and "if (secondlen > 0)". So this patch can be dropped.

Stanislaw

> On Fri, Feb 15, 2013 at 10:52:21AM +0100, Stanislaw Gruszka wrote:
> > This should fix:
> > 
> > drivers/net/wireless/iwlegacy/4965-mac.c:1847:33: warning: 'phys_addr' may be used uninitialized in this function [-Wmaybe-uninitialized]
> > 
> > Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> > Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> > ---
> >  drivers/net/wireless/iwlegacy/4965-mac.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
> > index 7941eb3..d2ab1cf 100644
> > --- a/drivers/net/wireless/iwlegacy/4965-mac.c
> > +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
> > @@ -1843,7 +1843,7 @@ il4965_tx_skb(struct il_priv *il,
> >  	il->ops->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0);
> >  	dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
> >  	dma_unmap_len_set(out_meta, len, firstlen);
> > -	if (secondlen)
> > +	if (secondlen > 0)
> >  		il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen,
> >  					       0, 0);
> >  
> > -- 
> > 1.7.11.7
> > 
> > 
> 
> -- 
> John W. Linville		Someday the world will need a hero, and you
> linville@tuxdriver.com			might be all we have.  Be ready.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 7941eb3..d2ab1cf 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -1843,7 +1843,7 @@  il4965_tx_skb(struct il_priv *il,
 	il->ops->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0);
 	dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
 	dma_unmap_len_set(out_meta, len, firstlen);
-	if (secondlen)
+	if (secondlen > 0)
 		il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen,
 					       0, 0);