LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Julia Lawall <julia.lawall@lip6.fr>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
linux-clk <linux-clk@vger.kernel.org>,
linux-crypto@vger.kernel.org,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
linux-i2c@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-mtd <linux-mtd@lists.infradead.org>,
Networking <netdev@vger.kernel.org>,
ALSA Development Mailing List <alsa-devel@alsa-project.org>,
DTML <devicetree@vger.kernel.org>
Subject: Re: [PATCH] treewide: remove redundent IS_ERR() before error code check
Date: Tue, 7 Jan 2020 15:28:33 +0900 [thread overview]
Message-ID: <CAK7LNATbLESJ6CdPSN8bdpt7+4iOKW2L3c4OZaz2sLzqJH6BTw@mail.gmail.com> (raw)
In-Reply-To: <20200107051521.GF705@sol.localdomain>
On Tue, Jan 7, 2020 at 2:15 PM Eric Biggers <ebiggers@kernel.org> wrote:
>
> On Mon, Jan 06, 2020 at 01:58:33PM +0900, Masahiro Yamada wrote:
> > 'PTR_ERR(p) == -E*' is a stronger condition than IS_ERR(p).
> > Hence, IS_ERR(p) is unneeded.
> >
> > The semantic patch that generates this commit is as follows:
> >
> > // <smpl>
> > @@
> > expression ptr;
> > constant error_code;
> > @@
> > -IS_ERR(ptr) && (PTR_ERR(ptr) == - error_code)
> > +PTR_ERR(ptr) == - error_code
> > // </smpl>
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> Any reason for not doing instead:
>
> ptr == ERR_PTR(-error_code)
>
> ?
Because there is no reason to change
PTR_ERR(ptr) == -error_code
to
ptr == ERR_PTR(-error_code)
if (PTR_ERR(ptr) == -error_code)
style seems to be used more often.
But, I think it is just a matter of preference after all.
Both work equally fine.
> To me it seems weird to use PTR_ERR() on non-error pointers. I even had to
> double check that it returns a 'long' and not an 'int'. (If it returned an
> 'int', it wouldn't work...)
>
> - Eric
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2020-01-07 6:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-06 4:58 Masahiro Yamada
2020-01-06 6:02 ` Stephen Boyd
2020-01-06 9:38 ` Bartosz Golaszewski
2020-01-06 10:05 ` Wolfram Sang
2020-01-07 5:15 ` Eric Biggers
2020-01-07 6:28 ` Masahiro Yamada [this message]
2020-01-07 9:52 ` Rafael J. Wysocki
2020-01-08 20:17 ` Rob Herring
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=CAK7LNATbLESJ6CdPSN8bdpt7+4iOKW2L3c4OZaz2sLzqJH6BTw@mail.gmail.com \
--to=masahiroy@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alsa-devel@alsa-project.org \
--cc=devicetree@vger.kernel.org \
--cc=ebiggers@kernel.org \
--cc=julia.lawall@lip6.fr \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--subject='Re: [PATCH] treewide: remove redundent IS_ERR() before error code check' \
/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
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).