[3/3] net/ena: fix build for O1 optimization

Message ID 20200507120259.2197813-3-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Headers
Series [1/3] ring: fix build for gcc O1 optimization |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot warning Travis build: failed
ci/Intel-compilation success Compilation OK

Commit Message

Ferruh Yigit May 7, 2020, 12:02 p.m. UTC
  Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
.../drivers/net/ena/ena_ethdev.c: In function ‘eth_ena_dev_init’:
.../drivers/net/ena/ena_ethdev.c:1815:20:
    error: ‘wd_state’ may be used uninitialized in this function
           [-Werror=maybe-uninitialized]
 1815 |  adapter->wd_state = wd_state;
      |  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~

This looks like false positive, fixing by assigning initial value to
'wd_state' variable.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Michal Krawczyk May 8, 2020, 1:59 p.m. UTC | #1
czw., 7 maj 2020 o 14:03 Ferruh Yigit <ferruh.yigit@intel.com> napisał(a):
>
> Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using
> gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
>
> Build error:
> .../drivers/net/ena/ena_ethdev.c: In function ‘eth_ena_dev_init’:
> .../drivers/net/ena/ena_ethdev.c:1815:20:
>     error: ‘wd_state’ may be used uninitialized in this function
>            [-Werror=maybe-uninitialized]
>  1815 |  adapter->wd_state = wd_state;
>       |  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
>
> This looks like false positive, fixing by assigning initial value to
> 'wd_state' variable.
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Michal Krawczyk <mk@semihalf.com>
> ---
>  drivers/net/ena/ena_ethdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> index c3fd3a4ac0..fbddc79f79 100644
> --- a/drivers/net/ena/ena_ethdev.c
> +++ b/drivers/net/ena/ena_ethdev.c
> @@ -1756,7 +1756,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
>         int rc;
>         static int adapters_found;
>         bool disable_meta_caching;
> -       bool wd_state;
> +       bool wd_state = false;
>
>         eth_dev->dev_ops = &ena_dev_ops;
>         eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;
> --
> 2.25.4
>
  

Patch

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index c3fd3a4ac0..fbddc79f79 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1756,7 +1756,7 @@  static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	int rc;
 	static int adapters_found;
 	bool disable_meta_caching;
-	bool wd_state;
+	bool wd_state = false;
 
 	eth_dev->dev_ops = &ena_dev_ops;
 	eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;