* [PATCH] dpaa_eth: avoid uninitialized variable false-positive warning
@ 2017-11-03 12:52 Arnd Bergmann
2017-11-05 13:13 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-11-03 12:52 UTC (permalink / raw)
To: Madalin Bucur
Cc: Arnd Bergmann, David S. Miller, Jiri Pirko, Jamal Hadi Salim,
Camelia Groza, yuan linyu, Claudiu Manoil, netdev, linux-kernel
We can now build this driver on ARM, so I ran into a randconfig build
warning that presumably had existed on powerpc already.
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c: In function 'sg_fd_to_skb':
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:1712:18: error: 'skb' may be used uninitialized in this function [-Werror=maybe-uninitialized]
I'm slightly changing the logic here, to make it obvious to the
compiler that 'skb' is always initialized.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 969f6b12952e..ebc55b6a6349 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -1721,6 +1721,7 @@ static struct sk_buff *sg_fd_to_skb(const struct dpaa_priv *priv,
/* Iterate through the SGT entries and add data buffers to the skb */
sgt = vaddr + fd_off;
+ skb = NULL;
for (i = 0; i < DPAA_SGT_MAX_ENTRIES; i++) {
/* Extension bit is not supported */
WARN_ON(qm_sg_entry_is_ext(&sgt[i]));
@@ -1738,7 +1739,7 @@ static struct sk_buff *sg_fd_to_skb(const struct dpaa_priv *priv,
count_ptr = this_cpu_ptr(dpaa_bp->percpu_count);
dma_unmap_single(dpaa_bp->dev, sg_addr, dpaa_bp->size,
DMA_FROM_DEVICE);
- if (i == 0) {
+ if (!skb) {
sz = dpaa_bp->size +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
skb = build_skb(sg_vaddr, sz);
--
2.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dpaa_eth: avoid uninitialized variable false-positive warning
2017-11-03 12:52 [PATCH] dpaa_eth: avoid uninitialized variable false-positive warning Arnd Bergmann
@ 2017-11-05 13:13 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-11-05 13:13 UTC (permalink / raw)
To: arnd
Cc: madalin.bucur, jiri, jhs, camelia.groza, Linyu.Yuan,
claudiu.manoil, netdev, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 3 Nov 2017 13:52:24 +0100
> We can now build this driver on ARM, so I ran into a randconfig build
> warning that presumably had existed on powerpc already.
>
> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c: In function 'sg_fd_to_skb':
> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:1712:18: error: 'skb' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> I'm slightly changing the logic here, to make it obvious to the
> compiler that 'skb' is always initialized.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-05 13:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 12:52 [PATCH] dpaa_eth: avoid uninitialized variable false-positive warning Arnd Bergmann
2017-11-05 13:13 ` David Miller
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).