diff mbox series

qed: Fix -Wmaybe-uninitialized false positive

Message ID 20190617130504.1906523-1-arnd@arndb.de
State Accepted
Commit 815deee0e34503dee7e74fb5ba4ea4a9b3a56750
Headers show
Series qed: Fix -Wmaybe-uninitialized false positive | expand

Commit Message

Arnd Bergmann June 17, 2019, 1:04 p.m. UTC
A previous attempt to shut up the uninitialized variable use
warning was apparently insufficient. When CONFIG_PROFILE_ANNOTATED_BRANCHES
is set, gcc-8 still warns, because the unlikely() check in DP_NOTICE()
causes it to no longer track the state of all variables correctly:

drivers/net/ethernet/qlogic/qed/qed_dev.c: In function 'qed_llh_set_ppfid_affinity':
drivers/net/ethernet/qlogic/qed/qed_dev.c:798:47: error: 'abs_ppfid' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  addr = NIG_REG_PPF_TO_ENGINE_SEL + abs_ppfid * 0x4;
                                     ~~~~~~~~~~^~~~~

This is not a nice workaround, but always initializing the output from
qed_llh_abs_ppfid() at least shuts up the false positive reliably.

Fixes: 79284adeb99e ("qed: Add llh ppfid interface and 100g support for offload protocols")
Fixes: 8e2ea3ea9625 ("qed: Fix static checker warning")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 1 +
 1 file changed, 1 insertion(+)

-- 
2.20.0

Comments

Michal Kalderon June 18, 2019, 9:27 a.m. UTC | #1
> From: Arnd Bergmann <arnd@arndb.de>

> Sent: Monday, June 17, 2019 4:05 PM

> 

> A previous attempt to shut up the uninitialized variable use warning was

> apparently insufficient. When CONFIG_PROFILE_ANNOTATED_BRANCHES is

> set, gcc-8 still warns, because the unlikely() check in DP_NOTICE() causes it to

> no longer track the state of all variables correctly:

> 

> drivers/net/ethernet/qlogic/qed/qed_dev.c: In function

> 'qed_llh_set_ppfid_affinity':

> drivers/net/ethernet/qlogic/qed/qed_dev.c:798:47: error: 'abs_ppfid' may

> be used uninitialized in this function [-Werror=maybe-uninitialized]

>   addr = NIG_REG_PPF_TO_ENGINE_SEL + abs_ppfid * 0x4;

>                                      ~~~~~~~~~~^~~~~

> 

> This is not a nice workaround, but always initializing the output from

> qed_llh_abs_ppfid() at least shuts up the false positive reliably.

> 

> Fixes: 79284adeb99e ("qed: Add llh ppfid interface and 100g support for

> offload protocols")

> Fixes: 8e2ea3ea9625 ("qed: Fix static checker warning")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>  drivers/net/ethernet/qlogic/qed/qed_dev.c | 1 +

>  1 file changed, 1 insertion(+)

> 

> diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c

> b/drivers/net/ethernet/qlogic/qed/qed_dev.c

> index eec7cb65c7e6..a1ebc2b1ca0b 100644

> --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c

> +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c

> @@ -652,6 +652,7 @@ static int qed_llh_abs_ppfid(struct qed_dev *cdev, u8

> ppfid, u8 *p_abs_ppfid)

>  		DP_NOTICE(cdev,

>  			  "ppfid %d is not valid, available indices are

> 0..%hhd\n",

>  			  ppfid, p_llh_info->num_ppfid - 1);

> +		*p_abs_ppfid = 0;

>  		return -EINVAL;

>  	}

> 

> --

> 2.20.0


Thanks, 

Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
David Miller June 18, 2019, 5:44 p.m. UTC | #2
From: Arnd Bergmann <arnd@arndb.de>

Date: Mon, 17 Jun 2019 15:04:49 +0200

> A previous attempt to shut up the uninitialized variable use

> warning was apparently insufficient. When CONFIG_PROFILE_ANNOTATED_BRANCHES

> is set, gcc-8 still warns, because the unlikely() check in DP_NOTICE()

> causes it to no longer track the state of all variables correctly:

> 

> drivers/net/ethernet/qlogic/qed/qed_dev.c: In function 'qed_llh_set_ppfid_affinity':

> drivers/net/ethernet/qlogic/qed/qed_dev.c:798:47: error: 'abs_ppfid' may be used uninitialized in this function [-Werror=maybe-uninitialized]

>   addr = NIG_REG_PPF_TO_ENGINE_SEL + abs_ppfid * 0x4;

>                                      ~~~~~~~~~~^~~~~

> 

> This is not a nice workaround, but always initializing the output from

> qed_llh_abs_ppfid() at least shuts up the false positive reliably.

> 

> Fixes: 79284adeb99e ("qed: Add llh ppfid interface and 100g support for offload protocols")

> Fixes: 8e2ea3ea9625 ("qed: Fix static checker warning")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Applied to net-next.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index eec7cb65c7e6..a1ebc2b1ca0b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -652,6 +652,7 @@  static int qed_llh_abs_ppfid(struct qed_dev *cdev, u8 ppfid, u8 *p_abs_ppfid)
 		DP_NOTICE(cdev,
 			  "ppfid %d is not valid, available indices are 0..%hhd\n",
 			  ppfid, p_llh_info->num_ppfid - 1);
+		*p_abs_ppfid = 0;
 		return -EINVAL;
 	}