Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1625056 > unrolled thread

[PATCH] net/mlx4: suppress 'may be used uninitialized' warning

Started byGreg Thelen <gthelen@google.com>
First post2017-04-18 08:30 +0200
Last post2017-04-20 19:30 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net/mlx4: suppress 'may be used uninitialized' warning Greg Thelen <gthelen@google.com> - 2017-04-18 08:30 +0200
    Re: [PATCH] net/mlx4: suppress 'may be used uninitialized' warning Leon Romanovsky <leon@kernel.org> - 2017-04-18 09:10 +0200
      Re: [PATCH] net/mlx4: suppress 'may be used uninitialized' warning Greg Thelen <gthelen@google.com> - 2017-04-18 09:30 +0200
    Re: [PATCH] net/mlx4: suppress 'may be used uninitialized' warning David Miller <davem@davemloft.net> - 2017-04-20 19:30 +0200

#1625056 — [PATCH] net/mlx4: suppress 'may be used uninitialized' warning

FromGreg Thelen <gthelen@google.com>
Date2017-04-18 08:30 +0200
Subject[PATCH] net/mlx4: suppress 'may be used uninitialized' warning
Message-ID<txuOd-2MU-5@gated-at.bofh.it>
gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
'mpt' variable:
  drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
  drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]
     mpt->mtt = mtt;

I think this warning is a false complaint.  mpt is only used when
mr_res_start_move_to() return zero, and in all such cases it initializes
mpt.  But apparently gcc cannot see that.

Initialize mpt to avoid the warning.

Signed-off-by: Greg Thelen <gthelen@google.com>
---
 drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index d8d5d161b8c7..4aa29ee93013 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -2749,7 +2749,7 @@ int mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave,
 	int err;
 	int index = vhcr->in_modifier;
 	struct res_mtt *mtt;
-	struct res_mpt *mpt;
+	struct res_mpt *mpt = NULL;
 	int mtt_base = mr_get_mtt_addr(inbox->buf) / dev->caps.mtt_entry_sz;
 	int phys;
 	int id;
-- 
2.12.2.762.g0e3151a226-goog

[toc] | [next] | [standalone]


#1625087

FromLeon Romanovsky <leon@kernel.org>
Date2017-04-18 09:10 +0200
Message-ID<txvqW-3eI-9@gated-at.bofh.it>
In reply to#1625056

[Multipart message — attachments visible in raw view] — view raw

On Mon, Apr 17, 2017 at 11:21:35PM -0700, Greg Thelen wrote:
> gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
> 'mpt' variable:
>   drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
>   drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]
>      mpt->mtt = mtt;
>
> I think this warning is a false complaint.  mpt is only used when
> mr_res_start_move_to() return zero, and in all such cases it initializes
> mpt.
> But apparently gcc cannot see that.
>
> Initialize mpt to avoid the warning.
>
> Signed-off-by: Greg Thelen <gthelen@google.com>
> ---

It looks like other callers of mr_res_start_move_to() have the same
"uninitialized" variable.

Thanks

[toc] | [prev] | [next] | [standalone]


#1625098

FromGreg Thelen <gthelen@google.com>
Date2017-04-18 09:30 +0200
Message-ID<txvKi-3lc-7@gated-at.bofh.it>
In reply to#1625087
Leon Romanovsky <leon@kernel.org> wrote:

> [ Unknown signature status ]
> On Mon, Apr 17, 2017 at 11:21:35PM -0700, Greg Thelen wrote:
>> gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
>> 'mpt' variable:
>>   drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
>>   drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]
>>      mpt->mtt = mtt;
>>
>> I think this warning is a false complaint.  mpt is only used when
>> mr_res_start_move_to() return zero, and in all such cases it initializes
>> mpt.
>> But apparently gcc cannot see that.
>>
>> Initialize mpt to avoid the warning.
>>
>> Signed-off-by: Greg Thelen <gthelen@google.com>
>> ---
>
> It looks like other callers of mr_res_start_move_to() have the same
> "uninitialized" variable.
>
> Thanks

The above is the only mellanox warning I see.  So gcc is able to better
analyze the other callsites.

[toc] | [prev] | [next] | [standalone]


#1627696

FromDavid Miller <davem@davemloft.net>
Date2017-04-20 19:30 +0200
Message-ID<tyo41-3kI-3@gated-at.bofh.it>
In reply to#1625056
From: Greg Thelen <gthelen@google.com>
Date: Mon, 17 Apr 2017 23:21:35 -0700

> gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
> 'mpt' variable:
>   drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
>   drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]
>      mpt->mtt = mtt;
> 
> I think this warning is a false complaint.  mpt is only used when
> mr_res_start_move_to() return zero, and in all such cases it initializes
> mpt.  But apparently gcc cannot see that.
> 
> Initialize mpt to avoid the warning.
> 
> Signed-off-by: Greg Thelen <gthelen@google.com>

Appied to net-next.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web