Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759126AbYAPWg5 (ORCPT ); Wed, 16 Jan 2008 17:36:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757449AbYAPWgJ (ORCPT ); Wed, 16 Jan 2008 17:36:09 -0500 Received: from saeurebad.de ([85.214.36.134]:36794 "EHLO saeurebad.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758594AbYAPWgG (ORCPT ); Wed, 16 Jan 2008 17:36:06 -0500 From: Johannes Weiner To: Christoph Lameter Cc: Linus Torvalds , Linux Kernel Mailing List , penberg@cs.helsinki.fi Subject: Re: Why is the kfree() argument const? References: <87lk6pvii0.fsf@saeurebad.de> <87odblct19.fsf@saeurebad.de> Date: Wed, 16 Jan 2008 23:37:04 +0100 In-Reply-To: (Christoph Lameter's message of "Wed, 16 Jan 2008 14:20:50 -0800 (PST)") Message-ID: <87ir1tcs8f.fsf@saeurebad.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 929 Lines: 32 Hi, Christoph Lameter writes: > On Wed, 16 Jan 2008, Johannes Weiner wrote: > >> So if I got it right and you actually modify the memory you only got a >> const pointer to, you reach a level where you _have to_ break this >> policy and cast to a non-const pointer, as it is currently done in >> kfree(). No? > > Correct and we have gcc 4.2 currently spitting out warnings because of > casting to non const. Any idea how to convince gcc that this is okay? Two dirty hacks where gcc at least does not complain: void *y = (void *)x; and then pass y, or passing *(void **)&x directly. Both approaches seem just too ugly to silence a bogus warning. Hannes -- 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/