Re: [RFC] PTR_ERR: return 0 if ptr isn't an error value.

From: Rusty Russell
Date: Wed Jun 12 2013 - 19:50:35 EST


Uwe Kleine-KÃnig <u.kleine-koenig@xxxxxxxxxxxxxx> writes:
> Hello Rusty,
>
> [added akpm to Cc: who took the patch back then and Julia for the
> coccinelle part below]
>
> On Mon, Jun 03, 2013 at 11:59:15AM +0930, Rusty Russell wrote:
>>
>> Back in 2011, Uwe Kleine-KÃnig added the nonsensically-named
>> PTR_RET(), providing a means to avoid if() statements in code (commit
>> fa9ee9c4b9).
>>
>> Instead, just make PTR_ERR() return 0 if the pointer isn't an error
>> value. This is harmless, since PTR_ERR() should have never been
>> passed a non-error value. And GCC is usually smart enough to remove
>> the extra test if IS_ERR() has already been called.
> I wonder in which situations gcc fails to be smart enough. Did you check
> this?

Good q. I just wrote a simple test to confirm that GCC usually did,
then compared the text sizes. Since it was bigger, I assume GCC isn't
doing it all the time.

Hmm, first change is in do_debug. Ah, no surprise here:

if (notify_die(DIE_DEBUG, "debug", regs, PTR_ERR(&dr6), error_code,
SIGTRAP) == NOTIFY_STOP)
goto exit;

Huh? dr6 is on the stack? Ancient, fixed.

I'll wade through the other differences after the weekend...

Cheers,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/