From: Joe Perches <joe@perches.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>, rth@twiddle.net
Cc: ink@jurassic.park.msu.ru, mattst88@gmail.com,
linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: Fix warning comparing pointer to 0
Date: Wed, 24 Nov 2021 20:00:50 -0800 [thread overview]
Message-ID: <5391025983087ae9d1292387bc0b2b37c9c57863.camel@perches.com> (raw)
In-Reply-To: <1637748818-21730-1-git-send-email-jiapeng.chong@linux.alibaba.com>
On Wed, 2021-11-24 at 18:13 +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warning:
>
> ./arch/alpha/mm/fault.c:193:52-53: WARNING comparing pointer to 0.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
[]
> diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
[]
> @@ -190,7 +190,7 @@
>
> no_context:
> /* Are we prepared to handle this fault as an exception? */
> - if ((fixup = search_exception_tables(regs->pc)) != 0) {
> + if (!(fixup = search_exception_tables(regs->pc)) {
This is now a reversed test.
The more typical kernel style is:
fixup = search_exception_tables(regs->pc);
if (fixup) {
> unsigned long newpc;
> newpc = fixup_exception(dpf_reg, fixup, regs->pc);
> regs->pc = newpc;
and it looks as if newpc is unnecessary. Maybe:
---
arch/alpha/mm/fault.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index eee5102c3d889..364b6322629cb 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -192,10 +192,9 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
no_context:
/* Are we prepared to handle this fault as an exception? */
- if ((fixup = search_exception_tables(regs->pc)) != 0) {
- unsigned long newpc;
- newpc = fixup_exception(dpf_reg, fixup, regs->pc);
- regs->pc = newpc;
+ fixup = search_exception_tables(regs->pc)
+ if (fixup) {
+ regs->pc = fixup_exception(dpf_reg, fixup, regs->pc);
return;
}
prev parent reply other threads:[~2021-11-25 4:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 10:13 [PATCH] mm: Fix warning comparing pointer to 0 Jiapeng Chong
2021-11-25 3:39 ` kernel test robot
2021-11-25 4:00 ` Joe Perches [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=5391025983087ae9d1292387bc0b2b37c9c57863.camel@perches.com \
--to=joe@perches.com \
--cc=ink@jurassic.park.msu.ru \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=rth@twiddle.net \
/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;
as well as URLs for NNTP newsgroup(s).