From: Andrew Morton <akpm@linux-foundation.org>
To: CGEL <cgel.zte@gmail.com>
Cc: "Gustavo A . R . Silva" <gustavoars@kernel.org>,
Sergei Trofimovich <slyfox@gentoo.org>,
linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org,
Jing Yangyang <jing.yangyang@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] arch/ia64/kernel/module.c: fix bugon.cocci warnings
Date: Mon, 23 Aug 2021 12:31:38 -0700 [thread overview]
Message-ID: <20210823123138.7ce66561a0d108bbdffb25ff@linux-foundation.org> (raw)
In-Reply-To: <20210823015110.44069-1-jing.yangyang@zte.com.cn>
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)
prev parent reply other threads:[~2021-08-23 19:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 1:51 CGEL
2021-08-23 19:31 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210823123138.7ce66561a0d108bbdffb25ff@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=cgel.zte@gmail.com \
--cc=gustavoars@kernel.org \
--cc=jing.yangyang@zte.com.cn \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slyfox@gentoo.org \
--cc=zealci@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®