From: Andreas Schwab <schwab@suse.de>
To: Ingo Oeser <ioe-lkml@rameria.de>
Cc: Amit Choudhary <amit2030@yahoo.com>,
Bernd Petrovitsch <bernd@firmix.at>,
Jan Engelhardt <jengelh@linux01.gwdg.de>,
Pavel Machek <pavel@ucw.cz>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [DISCUSS] Make the variable NULL after freeing it.
Date: Mon, 01 Jan 2007 17:25:03 +0100 [thread overview]
Message-ID: <je3b6uhfz4.fsf@sykes.suse.de> (raw)
In-Reply-To: <200701011709.48349.ioe-lkml@rameria.de> (Ingo Oeser's message of "Mon, 1 Jan 2007 17:09:46 +0100")
Ingo Oeser <ioe-lkml@rameria.de> writes:
> Hi,
>
> On Monday, 1. January 2007 07:37, Amit Choudhary wrote:
>> --- Ingo Oeser <ioe-lkml@rameria.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@suse.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."
next prev parent reply other threads:[~2007-01-01 16:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-21 23:41 Amit Choudhary
2006-12-27 17:10 ` Pavel Machek
2006-12-28 8:54 ` Jan Engelhardt
2006-12-31 13:38 ` Bernd Petrovitsch
2007-01-01 0:43 ` Ingo Oeser
2007-01-01 1:05 ` YOSHIFUJI Hideaki / 吉藤英明
2007-01-01 6:37 ` Amit Choudhary
2007-01-01 16:09 ` Ingo Oeser
2007-01-01 16:25 ` Andreas Schwab [this message]
2007-01-01 21:40 ` Ingo Oeser
2007-01-01 21:42 ` Jan Engelhardt
2007-01-01 18:36 ` Pavel Machek
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=je3b6uhfz4.fsf@sykes.suse.de \
--to=schwab@suse.de \
--cc=amit2030@yahoo.com \
--cc=bernd@firmix.at \
--cc=ioe-lkml@rameria.de \
--cc=jengelh@linux01.gwdg.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®