[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.0809300939450.3389@nehalem.linux-foundation.org>
Date: Tue, 30 Sep 2008 09:46:59 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Mike Travis <travis@....com>
cc: Ingo Molnar <mingo@...e.hu>, Rusty Russell <rusty@...tcorp.com.au>,
Yinghai Lu <yhlu.kernel@...il.com>,
David Miller <davem@...emloft.net>, Alan.Brunelle@...com,
tglx@...utronix.de, rjw@...k.pl,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
kernel-testers@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
arjan@...ux.intel.com, Jack Steiner <steiner@....com>
Subject: Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c -
bisected
On Tue, 30 Sep 2008, Mike Travis wrote:
>
> One pain is:
>
> typedef struct __cpumask_s *cpumask_t;
> const cpumask_t xxx;
>
> is not the same as:
>
> typedef const struct __cpumask_s *const_cpumask_t;
> const_cpumask_t xxx;
>
> and I'm not exactly sure why.
Umm. The const has different
One is
typedef const struct __cpumask_s *const_cpumask_t;
which becomes
(const struct __cpumask_s) *
while the other is
const cpumask_t xxx
which is
const (struct __cpumask_s *)
and if you look a bit more closely, you'll see that they are _obviously_
not the same thing at all.
Quite frankly, I personally do hate typedefs that end up being pointers,
and used as pointers, without showing that in the source code.
When you do
type_t a;
fn(a);
I expect the code to essentially do a pass-by-value. But when the type_t
is a pointer, that doesn't really work.
Your issue with 'const' is just another version of the same. You don't
want the _pointer_ to be const, you want what it points _to_ to be const.
But because you hid the pointerness inside the typedef, you simply cannot
do that.
The problem with cpumask's, of course, is that for the "small mask" case,
we really don't want it to be a pointer. So now it's sometimes a pointer
and sometimes not. The typedef hides that, and I understand why it's a
good idea, but I'm surprised you didn't understand what the implications
were for 'const', and I'm now a bit more leery about this whole thing just
because the typedef ends up hiding so much - it doesn't just hide the
basic type, it hides a very basic *code* issue.
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