Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759915AbYAROxy (ORCPT ); Fri, 18 Jan 2008 09:53:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753609AbYAROxq (ORCPT ); Fri, 18 Jan 2008 09:53:46 -0500 Received: from unthought.net ([212.97.129.88]:46443 "EHLO unthought.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753512AbYAROxp (ORCPT ); Fri, 18 Jan 2008 09:53:45 -0500 Date: Fri, 18 Jan 2008 15:53:44 +0100 From: Jakob Oestergaard To: =?iso-8859-1?Q?Bj=F6rn?= Steinbrink Cc: Linus Torvalds , David Schwartz , Johannes Weiner , Linux Kernel Mailing List , clameter@sgi.com, penberg@cs.helsinki.fi Subject: Re: Why is the kfree() argument const? Message-ID: <20080118145343.GR25527@unthought.net> Mail-Followup-To: Jakob Oestergaard , =?iso-8859-1?Q?Bj=F6rn?= Steinbrink , Linus Torvalds , David Schwartz , Johannes Weiner , Linux Kernel Mailing List , clameter@sgi.com, penberg@cs.helsinki.fi References: <20080118094826.GN25527@unthought.net> <20080118133116.GA31790@atjola.homenet> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20080118133116.GA31790@atjola.homenet> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1413 Lines: 44 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/