提交 92f97c00 编写于 作者: N Nathan Chancellor 提交者: Jakub Kicinski

net/mlx5e: Do not use err uninitialized in mlx5e_rep_add_meta_tunnel_rule()

Clang warns:

  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
          if (IS_ERR(flow_rule)) {
              ^~~~~~~~~~~~~~~~~
  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:489:9: note: uninitialized use occurs here
          return err;
                ^~~
  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:481:2: note: remove the 'if' if its condition is always true
          if (IS_ERR(flow_rule)) {
          ^~~~~~~~~~~~~~~~~~~~~~~
  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:474:9: note: initialize the variable 'err' to silence this warning
          int err;
                ^
                  = 0
  1 error generated.

There is little reason to have the 'goto + error variable' construct in
this function. Get rid of it and just return the PTR_ERR value in the if
statement and 0 at the end.

Fixes: 430e2d5e ("net/mlx5: E-Switch, Move send to vport meta rule creation")
Link: https://github.com/ClangBuiltLinux/linux/issues/1695Signed-off-by: NNathan Chancellor <nathan@kernel.org>
Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20220825180607.2707947-1-nathan@kernel.orgSigned-off-by: NJakub Kicinski <kuba@kernel.org>
上级 4f99de7b
...@@ -471,22 +471,18 @@ mlx5e_rep_add_meta_tunnel_rule(struct mlx5e_priv *priv) ...@@ -471,22 +471,18 @@ mlx5e_rep_add_meta_tunnel_rule(struct mlx5e_priv *priv)
struct mlx5_eswitch_rep *rep = rpriv->rep; struct mlx5_eswitch_rep *rep = rpriv->rep;
struct mlx5_flow_handle *flow_rule; struct mlx5_flow_handle *flow_rule;
struct mlx5_flow_group *g; struct mlx5_flow_group *g;
int err;
g = esw->fdb_table.offloads.send_to_vport_meta_grp; g = esw->fdb_table.offloads.send_to_vport_meta_grp;
if (!g) if (!g)
return 0; return 0;
flow_rule = mlx5_eswitch_add_send_to_vport_meta_rule(esw, rep->vport); flow_rule = mlx5_eswitch_add_send_to_vport_meta_rule(esw, rep->vport);
if (IS_ERR(flow_rule)) { if (IS_ERR(flow_rule))
err = PTR_ERR(flow_rule); return PTR_ERR(flow_rule);
goto out;
}
rpriv->send_to_vport_meta_rule = flow_rule; rpriv->send_to_vport_meta_rule = flow_rule;
out: return 0;
return err;
} }
static void static void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册