[v6,10/12] net/i40e: clean LTO build warnings (maybe-uninitialized)

Message ID 20191029141212.4907-11-aostruszka@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Add an option to use LTO for DPDK build |

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Andrzej Ostruszka [C] Oct. 29, 2019, 2:12 p.m. UTC
  During LTO build compiler reports some 'false positive' warnings about
variables being possibly used uninitialized.  This patch silences these
warnings.

Exemplary compiler warning to suppress (with LTO enabled):
error: ‘filter_idx’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
  PMD_DRV_LOG(INFO, "Added port %d with AQ command with index %d",

Signed-off-by: Andrzej Ostruszka <aostruszka@marvell.com>
---
 drivers/net/i40e/i40e_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Xing, Beilei Nov. 1, 2019, 2:05 a.m. UTC | #1
> -----Original Message-----
> From: Andrzej Ostruszka [mailto:aostruszka@marvell.com]
> Sent: Tuesday, October 29, 2019 10:12 PM
> To: dev@dpdk.org; Xing, Beilei <beilei.xing@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: mattias.ronnblom@ericsson.com; stephen@networkplumber.org
> Subject: [PATCH v6 10/12] net/i40e: clean LTO build warnings (maybe-
> uninitialized)
> 
> During LTO build compiler reports some 'false positive' warnings about
> variables being possibly used uninitialized.  This patch silences these warnings.
> 
> Exemplary compiler warning to suppress (with LTO enabled):
> error: ‘filter_idx’ may be used uninitialized in this function [-Werror=maybe-
> uninitialized]
>   PMD_DRV_LOG(INFO, "Added port %d with AQ command with index %d",

Hi,

Thanks for the patch. Please also add fix line here and Cc stable.

> 
> Signed-off-by: Andrzej Ostruszka <aostruszka@marvell.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 77a46832c..91d529b2f 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -8480,7 +8480,7 @@ static int
>  i40e_add_vxlan_port(struct i40e_pf *pf, uint16_t port, int udp_type)  {
>  	int  idx, ret;
> -	uint8_t filter_idx;
> +	uint8_t filter_idx = 0;
>  	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
> 
>  	idx = i40e_get_vxlan_port_idx(pf, port);
> --
> 2.17.1
  
Andrzej Ostruszka Nov. 4, 2019, 2:06 p.m. UTC | #2
Beilei

Thank you for the comment, please see below.

On 11/1/19 3:05 AM, Xing, Beilei wrote:
>> -----Original Message-----
>> From: Andrzej Ostruszka [mailto:aostruszka@marvell.com]
[...]
>> Subject: [PATCH v6 10/12] net/i40e: clean LTO build warnings (maybe-
>> uninitialized)
>>
>> During LTO build compiler reports some 'false positive' warnings about
>> variables being possibly used uninitialized.  This patch silences these warnings.
>>
>> Exemplary compiler warning to suppress (with LTO enabled):
>> error: ‘filter_idx’ may be used uninitialized in this function [-Werror=maybe-
>> uninitialized]
>>   PMD_DRV_LOG(INFO, "Added port %d with AQ command with index %d",
> 
> Hi,
> 
> Thanks for the patch. Please also add fix line here and Cc stable.

Are you saying that there is actually a problem in the code?

IMHO the code is fine and this patch just prevents gcc from issuing a
false warning.  What I think is going on is that gcc looks into
i40e_aq_add_udp_tunnel() and sees that filter_idx is updated under
condition "if (!status ..." and figures out that if status is positive
then filter_idx could be used uninitialized because in the calling
function we test "if (ret < 0)".  However it fails to take into account
the actual enum definition (only non-positive values) and the
implementation of i40e_asq_send_command().

So, if this is only work-around for the gcc deficiency, then I would
prefer to not add any fixline and to not pull that patch into stable.
Please let me know what you think.

Regards
Andrzej
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 77a46832c..91d529b2f 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -8480,7 +8480,7 @@  static int
 i40e_add_vxlan_port(struct i40e_pf *pf, uint16_t port, int udp_type)
 {
 	int  idx, ret;
-	uint8_t filter_idx;
+	uint8_t filter_idx = 0;
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 
 	idx = i40e_get_vxlan_port_idx(pf, port);