Message ID | 20240822043252.3488749-8-lizetao1@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 649c3c9b8e448f41f6249abcfe9a670a80fac7f7 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: Delete some redundant judgments | expand |
Li Zetao <lizetao1@huawei.com> writes: > The initial value of err is -ENOBUFS, and err is guaranteed to be > less than 0 before all goto errout. Therefore, on the error path > of errout, there is no need to repeatedly judge that err is less than 0, > and delete redundant judgments to make the code more concise. > > Signed-off-by: Li Zetao <lizetao1@huawei.com> Reviewed-by: Petr Machata <petrm@nvidia.com>
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 9db10d409074..93aaea0006ba 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -1090,8 +1090,7 @@ static void nexthop_notify(int event, struct nexthop *nh, struct nl_info *info) info->nlh, gfp_any()); return; errout: - if (err < 0) - rtnl_set_sk_err(info->nl_net, RTNLGRP_NEXTHOP, err); + rtnl_set_sk_err(info->nl_net, RTNLGRP_NEXTHOP, err); } static unsigned long nh_res_bucket_used_time(const struct nh_res_bucket *bucket) @@ -1211,8 +1210,7 @@ static void nexthop_bucket_notify(struct nh_res_table *res_table, rtnl_notify(skb, nh->net, 0, RTNLGRP_NEXTHOP, NULL, GFP_KERNEL); return; errout: - if (err < 0) - rtnl_set_sk_err(nh->net, RTNLGRP_NEXTHOP, err); + rtnl_set_sk_err(nh->net, RTNLGRP_NEXTHOP, err); } static bool valid_group_nh(struct nexthop *nh, unsigned int npaths,
The initial value of err is -ENOBUFS, and err is guaranteed to be less than 0 before all goto errout. Therefore, on the error path of errout, there is no need to repeatedly judge that err is less than 0, and delete redundant judgments to make the code more concise. Signed-off-by: Li Zetao <lizetao1@huawei.com> --- net/ipv4/nexthop.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)