From: Ziyang Xuan Date: Sat, 27 Aug 2022 07:20:11 +0000 (+0800) Subject: can: raw: use guard clause to optimize nesting in raw_rcv() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=170277c532780392051fee48260896ed280cfbef;p=linux.git can: raw: use guard clause to optimize nesting in raw_rcv() We can use guard clause to optimize nesting codes like if (condition) { ... } else { return; } in raw_rcv(); Signed-off-by: Ziyang Xuan Link: https://lore.kernel.org/all/0170ad1f07dbe838965df4274fce950980fa9d1f.1661584485.git.william.xuanziyang@huawei.com Signed-off-by: Marc Kleine-Budde --- diff --git a/net/can/raw.c b/net/can/raw.c index 9ae7c4206b9a3..e7dfa3584e29c 100644 --- a/net/can/raw.c +++ b/net/can/raw.c @@ -136,14 +136,13 @@ static void raw_rcv(struct sk_buff *oskb, void *data) /* eliminate multiple filter matches for the same skb */ if (this_cpu_ptr(ro->uniq)->skb == oskb && this_cpu_ptr(ro->uniq)->skbcnt == can_skb_prv(oskb)->skbcnt) { - if (ro->join_filters) { - this_cpu_inc(ro->uniq->join_rx_count); - /* drop frame until all enabled filters matched */ - if (this_cpu_ptr(ro->uniq)->join_rx_count < ro->count) - return; - } else { + if (!ro->join_filters) + return; + + this_cpu_inc(ro->uniq->join_rx_count); + /* drop frame until all enabled filters matched */ + if (this_cpu_ptr(ro->uniq)->join_rx_count < ro->count) return; - } } else { this_cpu_ptr(ro->uniq)->skb = oskb; this_cpu_ptr(ro->uniq)->skbcnt = can_skb_prv(oskb)->skbcnt;