[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080118145343.GR25527@unthought.net>
Date: Fri, 18 Jan 2008 15:53:44 +0100
From: Jakob Oestergaard <jakob@...hought.net>
To: Björn Steinbrink <B.Steinbrink@....de>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
David Schwartz <davids@...master.com>,
Johannes Weiner <hannes@...urebad.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
clameter@....com, penberg@...helsinki.fi
Subject: Re: Why is the kfree() argument const?
On Fri, Jan 18, 2008 at 02:31:16PM +0100, Björn Steinbrink wrote:
...
>
> Do you see anything that casts the const away? No? Me neither. Still,
> the memory that p points to was changed, because there was another
> pointer and that was not const.
*another* being key here.
>
> > *That* is the purpose of const pointers.
>
> The only thing that const can tell you is that you should not modify the
> value _yourself_, using that pointer _directly_.
Which is pretty damn useful.
Think about it. Don't you ever use const? Is it ever only in the way?
...
{snip long explanation about how one can avoid the benefits of const, without
using casts}
...
> If you want to restrict the set of pointers that can be invalidated by
> an other pointer, you'll have to use something else because const does
> not talk about invalidating aliasing pointers.
Precisely, so why are we discussing this?
I claim that const is useful. You claim that it can't solve all the worlds
problems. I agree with that, but I maintain it is still useful.
But, in order for it to be useful, it requires that people do not circumvent it
in the wrong places (such as kfree).
--
/ jakob
--
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