Messages in this thread | | | Date | Mon, 23 Aug 2021 12:31:38 -0700 | From | Andrew Morton <> | Subject | Re: [PATCH linux-next] arch/ia64/kernel/module.c: fix bugon.cocci warnings |
| |
On Sun, 22 Aug 2021 18:51:10 -0700 CGEL <cgel.zte@gmail.com> wrote:
> From: Jing Yangyang <jing.yangyang@zte.com.cn> > > Use BUG_ON instead of a if condition followed by BUG. > > Generated by: scripts/coccinelle/misc/bugon.cocci > > ... > > --- a/arch/ia64/kernel/module.c > +++ b/arch/ia64/kernel/module.c > @@ -560,8 +560,7 @@ struct plt_entry { > while (plt->bundle[0][0]) { > if (plt_target(plt) == target_ip) > goto found; > - if (++plt >= plt_end) > - BUG(); > + BUG_ON(++plt >= plt_end);
There are concerns that there might be a config combination in which BUG_ON() expands to a no-op. It this situation, `plt' won't get incremented and we have a bug.
Now, we have taken care to prevent this from happening, via the implementations of BUG_ON(). But still, mistakes happen and out of an abundance of caution people avoid statements of the form
assert(expression-with-side-effects)
| |