[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.0.999.0707231046140.3607@woody.linux-foundation.org>
Date: Mon, 23 Jul 2007 10:52:53 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Satyam Sharma <ssatyam@....iitk.ac.in>
cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
David Howells <dhowells@...hat.com>,
Nick Piggin <nickpiggin@...oo.com.au>, Andi Kleen <ak@...e.de>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 4/8] i386: bitops: Kill volatile-casting of memory
addresses
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
-
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