[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 01 Jan 2007 17:25:03 +0100
From: Andreas Schwab <schwab@...e.de>
To: Ingo Oeser <ioe-lkml@...eria.de>
Cc: Amit Choudhary <amit2030@...oo.com>,
Bernd Petrovitsch <bernd@...mix.at>,
Jan Engelhardt <jengelh@...ux01.gwdg.de>,
Pavel Machek <pavel@....cz>,
Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] [DISCUSS] Make the variable NULL after freeing it.
Ingo Oeser <ioe-lkml@...eria.de> writes:
> Hi,
>
> On Monday, 1. January 2007 07:37, Amit Choudhary wrote:
>> --- Ingo Oeser <ioe-lkml@...eria.de> wrote:
>> > #define kfree_nullify(x) do { \
>> > if (__builtin_constant_p(x)) { \
>> > kfree(x); \
>> > } else { \
>> > typeof(x) *__addr_x = &x; \
>
> Ok, I should change that line to
> typeof(x) *__addr_x = &(x); \
>
>> > kfree(*__addr_x); \
>> > *__addr_x = NULL; \
>> > } \
>> > } while (0)
>> >
>> > Regards
>> >
>> > Ingo Oeser
>> >
>>
>> This is a nice approach but what if someone does kfree_nullify(x+20).
>
> Then this works, because the side effect (+20) is evaluated only once.
It's not a side effect, it's a non-lvalue, and you can't take the address
of a non-lvalue.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@...e.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
-
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