* [PATCH] net/mlx5e: Don't use err uninitialized in mlx5e_attach_decap
@ 2020-05-27 7:50 Nathan Chancellor
2020-05-27 16:28 ` Saeed Mahameed
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2020-05-27 7:50 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky
Cc: netdev, linux-rdma, linux-kernel, clang-built-linux, Nathan Chancellor
Clang warns:
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3712:6: warning:
variable 'err' is used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
if (IS_ERR(d->pkt_reformat)) {
^~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3718:6: note:
uninitialized use occurs here
if (err)
^~~
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3712:2: note: remove the
'if' if its condition is always true
if (IS_ERR(d->pkt_reformat)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3670:9: note: initialize
the variable 'err' to silence this warning
int err;
^
= 0
1 warning generated.
It is not wrong, err is only ever initialized in if statements but this
one is not in one. Initialize err to 0 to fix this.
Fixes: 14e6b038afa0 ("net/mlx5e: Add support for hw decapsulation of MPLS over UDP")
Link: https://github.com/ClangBuiltLinux/linux/issues/1037
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index fdb7d2686c35..6d0d4896fe0c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -3667,7 +3667,7 @@ static int mlx5e_attach_decap(struct mlx5e_priv *priv,
struct mlx5e_decap_entry *d;
struct mlx5e_decap_key key;
uintptr_t hash_key;
- int err;
+ int err = 0;
parse_attr = attr->parse_attr;
if (sizeof(parse_attr->eth) > MLX5_CAP_ESW(priv->mdev, max_encap_header_size)) {
base-commit: d3d9065ad99d0d8d732c950cc0a37a7883cd0c60
--
2.27.0.rc0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net/mlx5e: Don't use err uninitialized in mlx5e_attach_decap
2020-05-27 7:50 [PATCH] net/mlx5e: Don't use err uninitialized in mlx5e_attach_decap Nathan Chancellor
@ 2020-05-27 16:28 ` Saeed Mahameed
0 siblings, 0 replies; 2+ messages in thread
From: Saeed Mahameed @ 2020-05-27 16:28 UTC (permalink / raw)
To: natechancellor, leon; +Cc: clang-built-linux, netdev, linux-rdma, linux-kernel
On Wed, 2020-05-27 at 00:50 -0700, Nathan Chancellor wrote:
> Clang warns:
>
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3712:6: warning:
> variable 'err' is used uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
> if (IS_ERR(d->pkt_reformat)) {
> ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3718:6: note:
> uninitialized use occurs here
> if (err)
> ^~~
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3712:2: note: remove
> the
> 'if' if its condition is always true
> if (IS_ERR(d->pkt_reformat)) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3670:9: note:
> initialize
> the variable 'err' to silence this warning
> int err;
> ^
> = 0
> 1 warning generated.
>
> It is not wrong, err is only ever initialized in if statements but
> this
> one is not in one. Initialize err to 0 to fix this.
>
> Fixes: 14e6b038afa0 ("net/mlx5e: Add support for hw decapsulation of
> MPLS over UDP")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1037
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
Applied to net-next-mlx5, will send shortly to net-next
Thanks,
Saeed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-27 16:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 7:50 [PATCH] net/mlx5e: Don't use err uninitialized in mlx5e_attach_decap Nathan Chancellor
2020-05-27 16:28 ` Saeed Mahameed
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).