[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFy2er_QwhherSPMuzPSMhTtDPjW3m0NYxC2j1-FhWJ-AA@mail.gmail.com>
Date: Wed, 8 Feb 2017 12:00:40 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Mike Galbraith <efault@....de>,
Oleg Nesterov <oleg@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH 03/10] sched/headers: Make task_struct::wake_q an opaque pointer
On Wed, Feb 8, 2017 at 10:34 AM, Ingo Molnar <mingo@...nel.org> wrote:
> To be able to decouple wake_q functionality from <linux/sched.h> make
> the basic task_struct::wake_q pointer an opaque void *.
Please don't use "void *" for opaque pointers.
You lose all typechecking, and this is just complete garbage:
+ struct wake_q_node *node = (void *)&task->wake_q;
What? You're casting a "void *" to "void *"? WTF?
The proper way to do opaque pointers is to declare them as pointers to
a structure that hasn't been defined (ie use a "struct xyz;" forward
declaration), and then that structure is only actually defined in the
places that use the otherwise opaque pointer.
That way you
(a) never need to cast anything
(b) get proper (and strong) type checking for the pointers.
and the people who need to look into it automatically do the right
thing, while anybody else who tries to dereference or otherwise use
the struct pointer will get a compiler error.
Linus
Powered by blists - more mailing lists