Re: [PATCH] include/linux/slab.h: new KFREE() macro.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Amit Choudhary <[email protected]> wrote:
> --- Christoph Hellwig <[email protected]> wrote:
>> On Sun, Jan 07, 2007 at 12:46:50AM -0800, Amit Choudhary wrote:

>> > Well, I am not proposing this as a debugging aid. The idea is about correct
>> > programming,
>> atleast
>> > from my view. Ideally, if you kfree(x), then you should set x to NULL. So,
>> > either programmers
>> do
>> > it themselves or a ready made macro do it for them.
>> 
>> No, you should not.  I suspect that's the basic point you're missing.

> Any strong reason why not? x has some value that does not make sense and can
> create only problems. And as I explained, it can result in longer code too.
> So, why keep this value around. Why not re-initialize it to NULL.

1) Because some magic value like 0x23 would be better.
2) Because it hides bugs like double frees or dangeling references while
   creating a race condition. In the end, you'll get more hard-to-find bugs
   in exchange for papering over some easy-to-spot bugs.

> If x should not be re-initialized to NULL, then by the same logic, we should
> not even initialize local variables. And all of us know that local variables
> should be initialized.

That may hide bugs, too. Therefore this isn't done in the kernel unless you
intend to depend on an initial value.
-- 
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.

http://david.woodhou.se/why-not-spf.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux