diff mbox series

[ovs-dev,v2] netdev-dpdk: Fix warning with gcc 13.

Message ID 20230531093754.134501-1-rjarry@redhat.com
State Accepted
Commit 8bcc6d694c8628820b0c924a4728e71e21828bd5
Headers show
Series [ovs-dev,v2] netdev-dpdk: Fix warning with gcc 13. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Robin Jarry May 31, 2023, 9:37 a.m. UTC
GCC now reports uninitialized warnings from function return values.

../lib/netdev-dpdk.c: In function 'netdev_dpdk_mempool_configure':
../lib/netdev-dpdk.c:964:22: warning: 'dmp' may be used uninitialized [-Wmaybe-uninitialized]
  964 |         dev->dpdk_mp = dmp;
      |         ~~~~~~~~~~~~~^~~~~
../lib/netdev-dpdk.c:854:21: note: 'dmp' was declared here
  854 |     struct dpdk_mp *dmp, *next;
      |                     ^~~

NB: this looks like a false positive, gcc 13 probably fails to see the link
between reuse and dmp in dpdk_mp_get().

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
---

Notes:
    v2: Fixed commit title and added note about possible false positive.

 lib/netdev-dpdk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilya Maximets June 2, 2023, 10:24 a.m. UTC | #1
On 5/31/23 11:37, Robin Jarry wrote:
> GCC now reports uninitialized warnings from function return values.
> 
> ../lib/netdev-dpdk.c: In function 'netdev_dpdk_mempool_configure':
> ../lib/netdev-dpdk.c:964:22: warning: 'dmp' may be used uninitialized [-Wmaybe-uninitialized]
>   964 |         dev->dpdk_mp = dmp;
>       |         ~~~~~~~~~~~~~^~~~~
> ../lib/netdev-dpdk.c:854:21: note: 'dmp' was declared here
>   854 |     struct dpdk_mp *dmp, *next;
>       |                     ^~~
> 
> NB: this looks like a false positive, gcc 13 probably fails to see the link
> between reuse and dmp in dpdk_mp_get().
> 
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> ---
> 
> Notes:
>     v2: Fixed commit title and added note about possible false positive.
> 
>  lib/netdev-dpdk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index fb0dd43f75c5..e11508cd5c31 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -840,7 +840,7 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
>  static struct dpdk_mp *
>  dpdk_mp_get(struct netdev_dpdk *dev, int mtu)
>  {
> -    struct dpdk_mp *dmp, *next;
> +    struct dpdk_mp *dmp = NULL, *next;
>      bool reuse = false;
>  
>      ovs_mutex_lock(&dpdk_mp_mutex);


Yeah, this definitely looks like a false-positive.  But I can reproduce
the warning and this patch is fixing it.  So, applied to branches down
to 2.17.  Thanks!

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index fb0dd43f75c5..e11508cd5c31 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -840,7 +840,7 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
 static struct dpdk_mp *
 dpdk_mp_get(struct netdev_dpdk *dev, int mtu)
 {
-    struct dpdk_mp *dmp, *next;
+    struct dpdk_mp *dmp = NULL, *next;
     bool reuse = false;
 
     ovs_mutex_lock(&dpdk_mp_mutex);