[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACxGe6vXmJ5F4MC826BPSui1pckEzNa5-iaRSXa6TqHdp=UYzw@mail.gmail.com>
Date: Wed, 9 Jan 2013 15:21:03 +0000
From: Grant Likely <grant.likely@...retlab.ca>
To: Russell King - ARM Linux <linux@....linux.org.uk>
Cc: Nicolas Pitre <nicolas.pitre@...aro.org>,
Arnd Bergmann <arnd@...db.de>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Alexandre Courbot <acourbot@...dia.com>,
Guenter Roeck <linux@...ck-us.net>,
"devicetree-discuss@...ts.ozlabs.org"
<devicetree-discuss@...ts.ozlabs.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] Proposed removal of IS_ERR_OR_NULL() (was: Re: [PATCH
1/4] gpiolib: introduce descriptor-based GPIO interface)
On Wed, Jan 9, 2013 at 3:04 PM, Russell King - ARM Linux
<linux@....linux.org.uk> wrote:
> So, it seems there's some concensus building here, and it seems that
> I've become the chosen victi^wvolunteer for this. So, here's a patch.
> It's missing a Guns-supplied-by: tag though.
>
> From: Russell King <rmk+kernel@....linux.org.uk>
> Subject: Mark IS_ERR_OR_NULL() deprecated
>
> IS_ERR_OR_NULL() attracts a lot of abuse: people use it without much
> thought about it's effects. Common errors include:
> 1. checking the returned pointer for functions defined as only
> returning errno-pointer values, rather than using IS_ERR().
> This leads to: ptr = foo(); if (IS_ERR_OR_NULL(ptr)) return
> PTR_ERR(ptr);
> 2. using it to check functions which only ever return NULL on error,
> thereby leading to another zero-error value return.
> In the case of debugfs functions, these return errno-pointer values when
> debugfs is configured out, which means code which blindly checks using
> IS_ERR_OR_NULL() ends up returning errors, which is rather perverse for
> something that's not implemented.
>
> Therefore, let's schedule it for removal in a few releases.
>
> Nicolas Pitre comments:
>> I do agree with Russell here. Despite the original intentions behind
>> IS_ERR_OR_NULL() which were certainly legitimate, the end result in
>> practice is less reliable code with increased maintenance costs.
>> Unlike other convenience macros in the kernel, this one is giving a
>> false sense of correctness with too many people falling in the trap
>> of using it just because it is available.
>>
>> I strongly think this macro should simply be removed from the source
>> tree entirely and the code reverted to explicit tests against NULL
>> when appropriate.
>
> Suggested-by: David Howells <dhowells@...hat.com>
> Tape-measuring-service-offered-by: Will Deacon <will.deacon@....com>
> Victim-for-firing-sqad: Russell King <rmk+kernel@....linux.org.uk>
> Signed-off-by: Russell King <rmk+kernel@....linux.org.uk>
Acked-by: Grant Likely <grant.likely@...retlab.ca>
I fully agree with doing this. While I'm not a fan of the PTR_ERR
pattern, this does (hopefully) make users think just a little bit more
about it.
> ---
> Ok, so I'm in the firing line for suggesting this, but it appears
> several people wish this to happen.
>
> I'm not intending to push this patch forwards _just_ yet: we need to
> sort out the existing users _first_ to prevent the kernel turning into
> one hell of a mess of warnings.
I currently see 355 users. That's a lot, but not inconceivable for an
auditing effort for pulling them out instead of scheduling for future
removal.
g.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists