Message ID | 20240822043252.3488749-3-lizetao1@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 41aa426392be26865a8a774df3e5ec4c56a98b26 |
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 -ENOMEM, 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/core/fib_rules.c b/net/core/fib_rules.c index 6ebffbc63236..3c76b835493d 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c @@ -1205,8 +1205,7 @@ static void notify_rule_change(int event, struct fib_rule *rule, rtnl_notify(skb, net, pid, ops->nlgroup, nlh, GFP_KERNEL); return; errout: - if (err < 0) - rtnl_set_sk_err(net, ops->nlgroup, err); + rtnl_set_sk_err(net, ops->nlgroup, err); } static void attach_rules(struct list_head *rules, struct net_device *dev)
The initial value of err is -ENOMEM, 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/core/fib_rules.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)