[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNATbLESJ6CdPSN8bdpt7+4iOKW2L3c4OZaz2sLzqJH6BTw@mail.gmail.com>
Date: Tue, 7 Jan 2020 15:28:33 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Eric Biggers <ebiggers@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Julia Lawall <julia.lawall@...6.fr>,
ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
linux-clk <linux-clk@...r.kernel.org>,
linux-crypto@...r.kernel.org,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
linux-i2c@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-mtd <linux-mtd@...ts.infradead.org>,
Networking <netdev@...r.kernel.org>,
ALSA Development Mailing List <alsa-devel@...a-project.org>,
DTML <devicetree@...r.kernel.org>
Subject: Re: [PATCH] treewide: remove redundent IS_ERR() before error code check
On Tue, Jan 7, 2020 at 2:15 PM Eric Biggers <ebiggers@...nel.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@...nel.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
Powered by blists - more mailing lists