From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932804AbXGWRx1 (ORCPT ); Mon, 23 Jul 2007 13:53:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761306AbXGWRxT (ORCPT ); Mon, 23 Jul 2007 13:53:19 -0400 Received: from smtp2.linux-foundation.org ([207.189.120.14]:48224 "EHLO smtp2.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761102AbXGWRxT (ORCPT ); Mon, 23 Jul 2007 13:53:19 -0400 Date: Mon, 23 Jul 2007 10:52:53 -0700 (PDT) From: Linus Torvalds To: Satyam Sharma cc: Linux Kernel Mailing List , David Howells , Nick Piggin , Andi Kleen , Andrew Morton Subject: Re: [PATCH 4/8] i386: bitops: Kill volatile-casting of memory addresses In-Reply-To: <20070723160548.22137.66072.sendpatchset@cselinux1.cse.iitk.ac.in> Message-ID: References: <20070723160528.22137.84144.sendpatchset@cselinux1.cse.iitk.ac.in> <20070723160548.22137.66072.sendpatchset@cselinux1.cse.iitk.ac.in> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 23 Jul 2007, Satyam Sharma wrote: > > [4/8] i386: bitops: Kill volatile-casting of memory addresses This is wrong. The "const volatile" is so that you can pass an arbitrary pointer. The only kind of abritraty pointer is "const volatile". In other words, the "volatile" has nothing at all to do with whether the memory is volatile or not (the same way "const" has nothing to do with it: it's purely a C type *safety* issue, exactly the same way "const" is a type safety issue. A "const" on a pointer doesn't mean that the thing it points to cannot change. When you pass a source pointer to "strlen()", it doesn't have to be constant. But "strlen()" takes a "const" pointer, because it work son constant pointers *too*. Same deal here. Admittedly this may be mostly historic, but regardless - the "volatiles" are right. Using volatile on *data* is generally considered incorrect and bad taste, but using it in situations like this potentially makes sense. Of course, if we remove all "volatiles" in data in the kernel (with the possible exception of "jiffies"), we can then remove them from function declarations too, but it should be done in that order. Linus