[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3f89cfece748d661cc0dc32b29704a3c0fa17fe4.camel@perches.com>
Date: Tue, 21 Dec 2021 02:47:44 -0800
From: Joe Perches <joe@...ches.com>
To: patchwork-bot+netdevbpf@...nel.org,
Yang Li <yang.lee@...ux.alibaba.com>
Cc: davem@...emloft.net, kuba@...nel.org, jhs@...atatu.com,
xiyou.wangcong@...il.com, jiri@...nulli.us, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, abaci@...ux.alibaba.com
Subject: Re: [PATCH -next] net/sched: use min() macro instead of doing it
manually
On Tue, 2021-12-21 at 10:20 +0000, patchwork-bot+netdevbpf@...nel.org
wrote:
> Hello:
>
> This patch was applied to netdev/net-next.git (master)
> by David S. Miller <davem@...emloft.net>:
>
> On Tue, 21 Dec 2021 09:14:55 +0800 you wrote:
> > Fix following coccicheck warnings:
> > ./net/sched/cls_api.c:3333:17-18: WARNING opportunity for min()
> > ./net/sched/cls_api.c:3389:17-18: WARNING opportunity for min()
> > ./net/sched/cls_api.c:3427:17-18: WARNING opportunity for min()
> >
> > Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> > Signed-off-by: Yang Li <yang.lee@...ux.alibaba.com>
> >
> > [...]
>
> Here is the summary with links:
> - [-next] net/sched: use min() macro instead of doing it manually
> https://git.kernel.org/netdev/net-next/c/c48c94b0ab75
>
> You are awesome, thank you!
The patch contained instances like:
---
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
[]
@@ -3333,7 +3333,7 @@ int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp,
up_read(&block->cb_lock);
if (take_rtnl)
rtnl_unlock();
- return ok_count < 0 ? ok_count : 0;
+ return min(ok_count, 0);
}
---
I think all of these min uses are somewhat obfuscating and not the
typically used kernel pattern.
If count is negative, it's an error return.
I believe the code would be clearer and more typical if written as:
if (ok_count < 0)
return ok_count;
return 0;
}
The compiler should produce the same object code.
Powered by blists - more mailing lists