diff options
author | Nadia Derbey <Nadia.Derbey@bull.net> | 2007-10-19 02:40:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:46 -0400 |
commit | 03f02c7657f7948ab980280c54c9366f962b1474 (patch) | |
tree | 7b1f564772077db0aed1e3c5a79ae77d2c1d2307 /ipc/msg.c | |
parent | 023a53557ea0e987b002e9a844242ef0b0aa1eb3 (diff) |
Storing ipcs into IDRs
This patch converts casts of struct kern_ipc_perm to
. struct msg_queue
. struct sem_array
. struct shmid_kernel
into the equivalent container_of() macro. It improves code maintenance
because the code need not change if kern_ipc_perm is no longer at the
beginning of the containing struct.
Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/msg.c')
-rw-r--r-- | ipc/msg.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -138,13 +138,17 @@ void __init msg_init(void) | |||
138 | 138 | ||
139 | static inline struct msg_queue *msg_lock(struct ipc_namespace *ns, int id) | 139 | static inline struct msg_queue *msg_lock(struct ipc_namespace *ns, int id) |
140 | { | 140 | { |
141 | return (struct msg_queue *) ipc_lock(&msg_ids(ns), id); | 141 | struct kern_ipc_perm *ipcp = ipc_lock(&msg_ids(ns), id); |
142 | |||
143 | return container_of(ipcp, struct msg_queue, q_perm); | ||
142 | } | 144 | } |
143 | 145 | ||
144 | static inline struct msg_queue *msg_lock_check(struct ipc_namespace *ns, | 146 | static inline struct msg_queue *msg_lock_check(struct ipc_namespace *ns, |
145 | int id) | 147 | int id) |
146 | { | 148 | { |
147 | return (struct msg_queue *) ipc_lock_check(&msg_ids(ns), id); | 149 | struct kern_ipc_perm *ipcp = ipc_lock_check(&msg_ids(ns), id); |
150 | |||
151 | return container_of(ipcp, struct msg_queue, q_perm); | ||
148 | } | 152 | } |
149 | 153 | ||
150 | static inline void msg_rmid(struct ipc_namespace *ns, struct msg_queue *s) | 154 | static inline void msg_rmid(struct ipc_namespace *ns, struct msg_queue *s) |
@@ -274,9 +278,11 @@ static void freeque(struct ipc_namespace *ns, struct msg_queue *msq) | |||
274 | ipc_rcu_putref(msq); | 278 | ipc_rcu_putref(msq); |
275 | } | 279 | } |
276 | 280 | ||
277 | static inline int msg_security(void *msq, int msgflg) | 281 | static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg) |
278 | { | 282 | { |
279 | return security_msg_queue_associate((struct msg_queue *) msq, msgflg); | 283 | struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); |
284 | |||
285 | return security_msg_queue_associate(msq, msgflg); | ||
280 | } | 286 | } |
281 | 287 | ||
282 | asmlinkage long sys_msgget(key_t key, int msgflg) | 288 | asmlinkage long sys_msgget(key_t key, int msgflg) |