Skip to contentSkip to conversation

net/avp: fix gcc 10 maybe-uninitialized warning

PATCH Superseded Kevin Traynor 6 participants 17 messages Feb 20, 2020 – May 6, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net/avp: fix gcc 10 maybe-uninitialized warning

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---
note, commit log violates line length but I didn't want to split warning msg.

Cc Steven Webster <[email protected]>
Cc Matt Peters <[email protected]>
---
 drivers/net/avp/avp_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/avp/avp_ethdev.c +1 -1
index cd747b6be..1abe96ce5 100644
@@ -1695,5 +1695,5 @@ avp_xmit_scattered_pkts(void *tx_queue,
 {
 	struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
-				       RTE_AVP_MAX_MBUF_SEGMENTS)];
+				       RTE_AVP_MAX_MBUF_SEGMENTS)] = {};
 	struct avp_queue *txq = (struct avp_queue *)tx_queue;
 	struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];
Signature · 1 line
2.21.1
#1 lore raw

PATCH 2/2 examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

Fix by initializing the array.

Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec library")

---
note, commit log violates line length but I didn't want to split warning msg.

Cc Radu Nicolau <[email protected]>
Cc Akhil Goyal <[email protected]>
---
 examples/ipsec-secgw/ipsec_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ipsec-secgw/ipsec_process.c +1 -1
index bb2f2b82d..0032c5c08 100644
@@ -287,5 +287,5 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 	struct rte_ipsec_group *pg;
 	struct rte_ipsec_session *ips;
-	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)];
+	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)] = {};
 
 	n = sa_group(trf->ipsec.saptr, trf->ipsec.pkts, grp, trf->ipsec.num);
Signature · 1 line
2.21.1
Acked-by on v1 2/2
#2 lore raw

Re: [dpdk-dev] [PATCH 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

Quoted 17 lines

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe- uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

Fix by initializing the array.

Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec

library")
Cc: [email protected]

Quoted 8 lines

---
note, commit log violates line length but I didn't want to split warning msg.

Cc Radu Nicolau <[email protected]>
Cc Akhil Goyal <[email protected]>

---

#3 lore raw

Re: [dpdk-dev] [PATCH 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

In reply to Kevin Traynor

Hi Kevin,

Quoted 29 lines

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

Fix by initializing the array.

Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec library")

---
note, commit log violates line length but I didn't want to split warning msg.

Cc Radu Nicolau <[email protected]>
Cc Akhil Goyal <[email protected]>
---
 examples/ipsec-secgw/ipsec_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/ipsec-secgw/ipsec_process.c +0 -0
index bb2f2b82d..0032c5c08 100644

examples/ipsec-secgw/ipsec_process.c ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf) · line 289

Quoted 4 lines
examples/ipsec-secgw/ipsec_process.c +1 -1
@@ -287,5 +287,5 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 	struct rte_ipsec_group *pg;
 	struct rte_ipsec_session *ips;
-	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)];
+	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)] = {};

Wouldn't that force to generate an extra instructions to zero-out a chunk of memory, grp pointitg to?
Considering that this is perf critical pass, that's probably not a best thing. If disabling compiler warning, is not an option, then probably something like code below would help?
Konstantin

examples/ipsec-secgw/ipsec_process.c +1 -0
index bb2f2b82d..6d3a3c9a1 100644
@@ -126,6 +126,7 @@ sa_group(void *sa_ptr[], struct rte_mbuf *pkts[],
        void * const nosa = &spi;
 
        sa = nosa;
+       grp[0].m = pkts;
        for (i = 0, n = 0; i != num; i++) {
 
                if (sa != sa_ptr[i]) {
#4 lore raw

Re: [dpdk-dev] [PATCH 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

Quoted 2 lines · Konstantin

Hi Kevin,

Hi Konstantin,

Quoted 24 lines
Quoted 24 lines

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

Fix by initializing the array.

Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec library")

---
note, commit log violates line length but I didn't want to split warning msg.

Cc Radu Nicolau <[email protected]>
Cc Akhil Goyal <[email protected]>
---
 examples/ipsec-secgw/ipsec_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

examples/ipsec-secgw/ipsec_process.c ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf) · line 289

Quoted 9 lines
examples/ipsec-secgw/ipsec_process.c +1 -1
index bb2f2b82d..0032c5c08 100644
@@ -287,5 +287,5 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 	struct rte_ipsec_group *pg;
 	struct rte_ipsec_session *ips;
-	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)];
+	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)] = {};

Wouldn't that force to generate an extra instructions to zero-out a chunk of memory, grp pointitg to?

Yes

Quoted 3 lines

Considering that this is perf critical pass, that's probably not a best thing. If disabling compiler warning, is not an option, then probably something like code below would help?

Yes, that is a nice suggestion - this will remove the warning with less instructions and LGTM.

In this case we can see that the code is safe because the grp[0].cnt is written with a valid value in the second instance but I suppose disabling the warning could mask something else later.

If you're ok with the approach below, I can prepare a v2 with your "Suggested-by". WDYT?

Kevin.

Quoted 15 lines

Konstantin

examples/ipsec-secgw/ipsec_process.c +1 -0
index bb2f2b82d..6d3a3c9a1 100644
@@ -126,6 +126,7 @@ sa_group(void *sa_ptr[], struct rte_mbuf *pkts[],
        void * const nosa = &spi;
 
        sa = nosa;
+       grp[0].m = pkts;
        for (i = 0, n = 0; i != num; i++) {
 
                if (sa != sa_ptr[i]) {
#5 lore raw

Re: [dpdk-dev] [PATCH 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

Quoted 46 lines
Quoted 24 lines
Quoted 24 lines

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

Fix by initializing the array.

Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec library")

---
note, commit log violates line length but I didn't want to split warning msg.

Cc Radu Nicolau <[email protected]>
Cc Akhil Goyal <[email protected]>
---
 examples/ipsec-secgw/ipsec_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

examples/ipsec-secgw/ipsec_process.c ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf) · line 289

Quoted 9 lines
examples/ipsec-secgw/ipsec_process.c +1 -1
index bb2f2b82d..0032c5c08 100644
@@ -287,5 +287,5 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 	struct rte_ipsec_group *pg;
 	struct rte_ipsec_session *ips;
-	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)];
+	struct rte_ipsec_group grp[RTE_DIM(trf->ipsec.pkts)] = {};

Wouldn't that force to generate an extra instructions to zero-out a chunk of memory, grp pointitg to?

Yes

Quoted 3 lines

Considering that this is perf critical pass, that's probably not a best thing. If disabling compiler warning, is not an option, then probably something like code below would help?

Yes, that is a nice suggestion - this will remove the warning with less instructions and LGTM.

Quoted 6 lines

In this case we can see that the code is safe because the grp[0].cnt is written with a valid value in the second instance but I suppose disabling the warning could mask something else later.

If you're ok with the approach below, I can prepare a v2 with your "Suggested-by". WDYT?

Sounds like a good plan to me.
Thanks
Konstantin

Quoted 18 lines

Kevin.

Quoted 15 lines

Konstantin

examples/ipsec-secgw/ipsec_process.c +1 -0
index bb2f2b82d..6d3a3c9a1 100644
@@ -126,6 +126,7 @@ sa_group(void *sa_ptr[], struct rte_mbuf *pkts[],
        void * const nosa = &spi;
 
        sa = nosa;
+       grp[0].m = pkts;
        for (i = 0, n = 0; i != num; i++) {
 
                if (sa != sa_ptr[i]) {
#6 lore raw

PATCH v2 1/2 net/avp: fix gcc 10 maybe-uninitialized warning

In reply to Kevin Traynor

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---
v2: no change

note, commit log violates line length but I didn't want to split warning msg.

Cc Steven Webster <[email protected]>
Cc Matt Peters <[email protected]>
---
 drivers/net/avp/avp_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/avp/avp_ethdev.c +1 -1
index cd747b6be..1abe96ce5 100644
@@ -1695,5 +1695,5 @@ avp_xmit_scattered_pkts(void *tx_queue,
 {
 	struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
-				       RTE_AVP_MAX_MBUF_SEGMENTS)];
+				       RTE_AVP_MAX_MBUF_SEGMENTS)] = {};
 	struct avp_queue *txq = (struct avp_queue *)tx_queue;
 	struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];
Signature · 1 line
2.21.1
#7 lore raw

PATCH v2 2/2 examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

This is a correct warning for the initial execution of the statement. However, it is the design of the loop that grp[0].cnt will later be written with the correct value using an initialized grp[0].m before it is used.

In order to remove the warning, initialize grp[0].m for the initial and unused calculation of grp[0].cnt.

Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec library")

---
v2: just initialize grp[0].m instead of the full array.

note, commit log violates line length but I didn't want to split warning msg.

Cc Radu Nicolau <[email protected]>
Cc Akhil Goyal <[email protected]>
---
 examples/ipsec-secgw/ipsec_process.c | 1 +
 1 file changed, 1 insertion(+)
examples/ipsec-secgw/ipsec_process.c +1 -0
index bb2f2b82d..6d3a3c9a1 100644
@@ -127,4 +127,5 @@ sa_group(void *sa_ptr[], struct rte_mbuf *pkts[],
 
 	sa = nosa;
+	grp[0].m = pkts;
 	for (i = 0, n = 0; i != num; i++) {
 
Signature · 1 line
2.21.1
Acked-by on v2 2/2
#8 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

Quoted 48 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, March 11, 2020 11:33 AM
To: [email protected]
Cc: Kevin Traynor <[email protected]>; [email protected]; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>
Subject: [PATCH v2 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

This is a correct warning for the initial execution of the statement. However, it is the design of the loop that grp[0].cnt will later be written with the correct value using an initialized grp[0].m before it is used.

In order to remove the warning, initialize grp[0].m for the initial and unused calculation of grp[0].cnt.

Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec library")

---
v2: just initialize grp[0].m instead of the full array.

note, commit log violates line length but I didn't want to split warning msg.

Cc Radu Nicolau <[email protected]>
Cc Akhil Goyal <[email protected]>
---
 examples/ipsec-secgw/ipsec_process.c | 1 +
 1 file changed, 1 insertion(+)
examples/ipsec-secgw/ipsec_process.c +0 -0
index bb2f2b82d..6d3a3c9a1 100644

examples/ipsec-secgw/ipsec_process.c sa_group(void *sa_ptr[], struct rte_mbuf *pkts[],

Quoted 6 lines
examples/ipsec-secgw/ipsec_process.c +1 -1
@@ -127,4 +127,5 @@ sa_group(void *sa_ptr[], struct rte_mbuf *pkts[],
 
 	sa = nosa;
+	grp[0].m = pkts;
 	for (i = 0, n = 0; i != num; i++) {
 
--
Quoted 1 line

2.21.1

#9 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

Quoted 23 lines · Konstantin
Quoted 23 lines

From: Kevin Traynor <[email protected]>
Sent: Wednesday, March 11, 2020 11:33 AM
To: [email protected]
Cc: Kevin Traynor <[email protected]>; [email protected]; Ananyev, Konstantin <[email protected]>; Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>
Subject: [PATCH v2 2/2] examples/ipsec-gw: fix gcc 10 maybe-uninitialized warning

gcc 10.0.1 reports:

../examples/ipsec-secgw/ipsec_process.c: In function ‘ipsec_process’:
../examples/ipsec-secgw/ipsec_process.c:132:34:
error: ‘grp.m’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
132 | grp[n].cnt = pkts + i - grp[n].m;
| ~~~~~~^~

This is a correct warning for the initial execution of the statement. However, it is the design of the loop that grp[0].cnt will later be written with the correct value using an initialized grp[0].m before it is used.

In order to remove the warning, initialize grp[0].m for the initial and unused calculation of grp[0].cnt.

Quoted 6 lines
Quoted 5 lines
Fixes 3e5f4625dc17 ("examples/ipsec-secgw: make data-path to use IPsec library")

Applied, thanks.

Signature · 1 line
David Marchand
Acked-by on v2 1/2
#10 lore raw
In reply to Kevin Traynor
Quoted 12 lines

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [- Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [- Wmaybe-uninitialized]

Quoted 7 lines

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---

#11 lore raw
Quoted 13 lines · Steven
Quoted 13 lines

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [- Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [- Wmaybe-uninitialized]

Quoted 8 lines
Quoted 7 lines

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---

Applied, thanks.

Signature · 1 line
David Marchand
#12 lore raw
In reply to Kevin Traynor
Quoted 34 lines · Kevin Traynor

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---
v2: no change

note, commit log violates line length but I didn't want to split warning msg.

Cc Steven Webster <[email protected]>
Cc Matt Peters <[email protected]>
---
 drivers/net/avp/avp_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/avp/avp_ethdev.c +0 -0
index cd747b6be..1abe96ce5 100644

drivers/net/avp/avp_ethdev.c avp_xmit_scattered_pkts(void *tx_queue, · line 1699

Quoted 6 lines
drivers/net/avp/avp_ethdev.c +1 -1
@@ -1695,5 +1695,5 @@ avp_xmit_scattered_pkts(void *tx_queue,
 {
 	struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
-				       RTE_AVP_MAX_MBUF_SEGMENTS)];
+				       RTE_AVP_MAX_MBUF_SEGMENTS)] = {};
 	struct avp_queue *txq = (struct avp_queue *)tx_queue;
 	struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];

Isn't this a false positive, can there be any case 'avp_bufs[]' used uninitialized? Or am I missing something.

If this is false positive, does it worth to report to issue to gcc?

#13 lore raw
Quoted 29 lines · Ferruh Yigit
Quoted 28 lines · Kevin Traynor

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---
v2: no change

note, commit log violates line length but I didn't want to split warning msg.

Cc Steven Webster <[email protected]>
Cc Matt Peters <[email protected]>
---
 drivers/net/avp/avp_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

drivers/net/avp/avp_ethdev.c avp_xmit_scattered_pkts(void *tx_queue, · line 1699

Quoted 12 lines
drivers/net/avp/avp_ethdev.c +1 -1
index cd747b6be..1abe96ce5 100644
@@ -1695,5 +1695,5 @@ avp_xmit_scattered_pkts(void *tx_queue,
 {
 	struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
-				       RTE_AVP_MAX_MBUF_SEGMENTS)];
+				       RTE_AVP_MAX_MBUF_SEGMENTS)] = {};
 	struct avp_queue *txq = (struct avp_queue *)tx_queue;
 	struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];

Isn't this a false positive, can there be any case 'avp_bufs[]' used uninitialized? Or am I missing something.

I presume it's because it's not being initialized in the fn and there is some paths in fn's it's passed to that don't initialize it. Of course in practice with "normal" values this might not happen.

Quoted 2 lines

If this is false positive, does it worth to report to issue to gcc?

#14 lore raw
Quoted 47 lines · Kevin Traynor
Quoted 29 lines · Ferruh Yigit
Quoted 28 lines · Kevin Traynor

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---
v2: no change

note, commit log violates line length but I didn't want to split warning msg.

Cc Steven Webster <[email protected]>
Cc Matt Peters <[email protected]>
---
 drivers/net/avp/avp_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

drivers/net/avp/avp_ethdev.c avp_xmit_scattered_pkts(void *tx_queue, · line 1699

Quoted 12 lines
drivers/net/avp/avp_ethdev.c +1 -1
index cd747b6be..1abe96ce5 100644
@@ -1695,5 +1695,5 @@ avp_xmit_scattered_pkts(void *tx_queue,
 {
 	struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
-				       RTE_AVP_MAX_MBUF_SEGMENTS)];
+				       RTE_AVP_MAX_MBUF_SEGMENTS)] = {};
 	struct avp_queue *txq = (struct avp_queue *)tx_queue;
 	struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];

Isn't this a false positive, can there be any case 'avp_bufs[]' used uninitialized? Or am I missing something.

Quoted 3 lines

I presume it's because it's not being initialized in the fn and there is some paths in fn's it's passed to that don't initialize it. Of course in practice with "normal" values this might not happen.

'avp_fifo_get(alloc_q, (void **)&avp_bufs, segments);' initializes it, and I am not just talking about 'normal' case, I don't see any case that 'avp_bufs[]' used uninitialized, can you see any?

Quoted 4 lines
Quoted 3 lines

If this is false positive, does it worth to report to issue to gcc?

#15 lore raw
Quoted 48 lines · Ferruh Yigit
Quoted 47 lines · Kevin Traynor
Quoted 45 lines · Ferruh Yigit
Quoted 34 lines · Kevin Traynor

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---
v2: no change

note, commit log violates line length but I didn't want to split warning msg.

Cc Steven Webster <[email protected]>
Cc Matt Peters <[email protected]>
---
 drivers/net/avp/avp_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/avp/avp_ethdev.c +0 -0
index cd747b6be..1abe96ce5 100644

drivers/net/avp/avp_ethdev.c avp_xmit_scattered_pkts(void *tx_queue, · line 1699

Quoted 6 lines
drivers/net/avp/avp_ethdev.c +1 -1
@@ -1695,5 +1695,5 @@ avp_xmit_scattered_pkts(void *tx_queue,
 {
 	struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
-				       RTE_AVP_MAX_MBUF_SEGMENTS)];
+				       RTE_AVP_MAX_MBUF_SEGMENTS)] = {};
 	struct avp_queue *txq = (struct avp_queue *)tx_queue;
 	struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];

Isn't this a false positive, can there be any case 'avp_bufs[]' used uninitialized? Or am I missing something.

Quoted 8 lines
Quoted 3 lines

I presume it's because it's not being initialized in the fn and there is some paths in fn's it's passed to that don't initialize it. Of course in practice with "normal" values this might not happen.

'avp_fifo_get(alloc_q, (void **)&avp_bufs, segments);' initializes it, and I am not just talking about 'normal' case, I don't see any case that 'avp_bufs[]' used uninitialized, can you see any?

Well, it's initialization there is dependent on not hitting the first return and the loop executing.

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

If this is false positive, does it worth to report to issue to gcc?

#16 lore raw
Quoted 53 lines · Kevin Traynor
Quoted 52 lines · Ferruh Yigit
Quoted 50 lines · Kevin Traynor
Quoted 29 lines · Ferruh Yigit
Quoted 28 lines · Kevin Traynor

gcc 10.0.1 reports:

../drivers/net/avp/avp_ethdev.c: In function ‘avp_xmit_scattered_pkts’:
../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

 1791 |   tx_bufs[i] = avp_bufs[count];
      |                ~~~~~~~~^~~~~~~

../drivers/net/avp/avp_ethdev.c:1791:24:
warning: ‘avp_bufs[count]’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Fix by intializing the array.

Fixes 295abce2d25b ("net/avp: add packet transmit functions")

---
v2: no change

note, commit log violates line length but I didn't want to split warning msg.

Cc Steven Webster <[email protected]>
Cc Matt Peters <[email protected]>
---
 drivers/net/avp/avp_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

drivers/net/avp/avp_ethdev.c avp_xmit_scattered_pkts(void *tx_queue, · line 1699

Quoted 12 lines
drivers/net/avp/avp_ethdev.c +1 -1
index cd747b6be..1abe96ce5 100644
@@ -1695,5 +1695,5 @@ avp_xmit_scattered_pkts(void *tx_queue,
 {
 	struct rte_avp_desc *avp_bufs[(AVP_MAX_TX_BURST *
-				       RTE_AVP_MAX_MBUF_SEGMENTS)];
+				       RTE_AVP_MAX_MBUF_SEGMENTS)] = {};
 	struct avp_queue *txq = (struct avp_queue *)tx_queue;
 	struct rte_avp_desc *tx_bufs[AVP_MAX_TX_BURST];

Isn't this a false positive, can there be any case 'avp_bufs[]' used uninitialized? Or am I missing something.

I presume it's because it's not being initialized in the fn and there is some paths in fn's it's passed to that don't initialize it. Of course in practice with "normal" values this might not happen.

Quoted 7 lines
Quoted 4 lines

'avp_fifo_get(alloc_q, (void **)&avp_bufs, segments);' initializes it, and I am not just talking about 'normal' case, I don't see any case that 'avp_bufs[]' used uninitialized, can you see any?

Well, it's initialization there is dependent on not hitting the first return and the loop executing.

If whole array not initialized, the next line, 'if (unlikely(n != segments))', will catch it and function return without using 'avp_bufs[]' at all.

Anyway, as I said I can't see a case that 'avp_bufs[]' used uninitialized, and not sure about additional zeroing out in datapath function if this is a false positive, but if windriver guys are OK I won't object.

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

If this is false positive, does it worth to report to issue to gcc?