Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1577009
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 03/10] sched/headers: Make task_struct::wake_q an opaque pointer |
| Date | 2017-02-08 21:10 +0100 |
| Message-ID | <t8GIV-4OC-11@gated-at.bofh.it> (permalink) |
| References | <t8FjQ-3Oi-11@gated-at.bofh.it> <t8FjQ-3Oi-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Feb 8, 2017 at 10:34 AM, Ingo Molnar <mingo@kernel.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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] sched.h modernization -v2, phase #1: "Pre-splitup cleanups" Ingo Molnar <mingo@kernel.org> - 2017-02-08 19:40 +0100
[PATCH 06/10] sched/core: Remove the tsk_nr_cpus_allowed() wrapper Ingo Molnar <mingo@kernel.org> - 2017-02-08 19:40 +0100
[PATCH 01/10] sched/headers: Make all include/linux/sched/*.h headers build standalone Ingo Molnar <mingo@kernel.org> - 2017-02-08 19:40 +0100
[PATCH 03/10] sched/headers: Make task_struct::wake_q an opaque pointer Ingo Molnar <mingo@kernel.org> - 2017-02-08 19:40 +0100
Re: [PATCH 03/10] sched/headers: Make task_struct::wake_q an opaque pointer Linus Torvalds <torvalds@linux-foundation.org> - 2017-02-08 21:10 +0100
[PATCH] sched/wake_q: Restore task_struct::wake_q type safety Ingo Molnar <mingo@kernel.org> - 2017-02-08 22:40 +0100
[PATCH 08/10] sched/headers, cgroups: Remove the threadgroup_change_*() wrappery Ingo Molnar <mingo@kernel.org> - 2017-02-08 19:50 +0100
[PATCH 10/10] kasan, sched/headers: Uninline kasan_enable/disable_current() Ingo Molnar <mingo@kernel.org> - 2017-02-08 20:10 +0100
[PATCH 09/10] mm/vmacache, sched/headers: Introduce 'struct vmacache' and move it from <linux/sched.h> to <linux/mm_types> Ingo Molnar <mingo@kernel.org> - 2017-02-08 20:50 +0100
[PATCH 07/10] rcu: Separate the RCU synchronization types and APIs into <linux/rcupdate_wait.h> Ingo Molnar <mingo@kernel.org> - 2017-02-08 20:50 +0100
Re: [PATCH 07/10] rcu: Separate the RCU synchronization types and APIs into <linux/rcupdate_wait.h> Paul McKenney <paulmckrcu@gmail.com> - 2017-02-11 20:20 +0100
Re: [PATCH 00/10] sched.h modernization -v2, phase #1: "Pre-splitup cleanups" Linus Torvalds <torvalds@linux-foundation.org> - 2017-02-08 21:30 +0100
csiph-web