diff mbox

[net-next,1/2] qlge: Fix compilation warning

Message ID 1407953289-23460-2-git-send-email-harish.patil@qlogic.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Harish Patil Aug. 13, 2014, 6:08 p.m. UTC
From: Harish Patil <harish.patil@qlogic.com>

Fix the below warning message observed during qlge compilation:
qlge_main.c:1754: warning: 'lbq_desc' may be used uninitialized in this function

Signed-off-by: Harish Patil <harish.patil@qlogic.com>
---
 drivers/net/ethernet/qlogic/qlge/qlge_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller Aug. 14, 2014, 9:31 p.m. UTC | #1
From: Harish Patil <harish.patil@qlogic.com>
Date: Wed, 13 Aug 2014 14:08:08 -0400

> From: Harish Patil <harish.patil@qlogic.com>
> 
> Fix the below warning message observed during qlge compilation:
> qlge_main.c:1754: warning: 'lbq_desc' may be used uninitialized in this function
> 
> Signed-off-by: Harish Patil <harish.patil@qlogic.com>

Please fix this differently.  The problem is that the compiler can't see that
you've done the !length check at the top of the function, so when it later
sees the while (length > 0) loop, it doesn't know that this loop will always
execute at least once.

Just change that loop to a do { } while() loop and the compiler will be able
to see everything.
--
To unsubscribe from this list: send the line "unsubscribe netdev" 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/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
index b40050e..767bcc5 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
@@ -1750,9 +1750,9 @@  static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
 				       struct rx_ring *rx_ring,
 				       struct ib_mac_iocb_rsp *ib_mac_rsp)
 {
-	struct bq_desc *lbq_desc;
-	struct bq_desc *sbq_desc;
+	struct bq_desc *lbq_desc = NULL;
 	struct sk_buff *skb = NULL;
+	struct bq_desc *sbq_desc;
 	u32 length = le32_to_cpu(ib_mac_rsp->data_len);
 	u32 hdr_len = le32_to_cpu(ib_mac_rsp->hdr_len);
 	size_t hlen = ETH_HLEN;