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/sem.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/sem.c')
-rw-r--r-- | ipc/sem.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -176,13 +176,17 @@ void __init sem_init (void) | |||
176 | 176 | ||
177 | static inline struct sem_array *sem_lock(struct ipc_namespace *ns, int id) | 177 | static inline struct sem_array *sem_lock(struct ipc_namespace *ns, int id) |
178 | { | 178 | { |
179 | return (struct sem_array *) ipc_lock(&sem_ids(ns), id); | 179 | struct kern_ipc_perm *ipcp = ipc_lock(&sem_ids(ns), id); |
180 | |||
181 | return container_of(ipcp, struct sem_array, sem_perm); | ||
180 | } | 182 | } |
181 | 183 | ||
182 | static inline struct sem_array *sem_lock_check(struct ipc_namespace *ns, | 184 | static inline struct sem_array *sem_lock_check(struct ipc_namespace *ns, |
183 | int id) | 185 | int id) |
184 | { | 186 | { |
185 | return (struct sem_array *) ipc_lock_check(&sem_ids(ns), id); | 187 | struct kern_ipc_perm *ipcp = ipc_lock_check(&sem_ids(ns), id); |
188 | |||
189 | return container_of(ipcp, struct sem_array, sem_perm); | ||
186 | } | 190 | } |
187 | 191 | ||
188 | static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) | 192 | static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) |
@@ -277,14 +281,21 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params) | |||
277 | } | 281 | } |
278 | 282 | ||
279 | 283 | ||
280 | static inline int sem_security(void *sma, int semflg) | 284 | static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg) |
281 | { | 285 | { |
282 | return security_sem_associate((struct sem_array *) sma, semflg); | 286 | struct sem_array *sma; |
287 | |||
288 | sma = container_of(ipcp, struct sem_array, sem_perm); | ||
289 | return security_sem_associate(sma, semflg); | ||
283 | } | 290 | } |
284 | 291 | ||
285 | static inline int sem_more_checks(void *sma, struct ipc_params *params) | 292 | static inline int sem_more_checks(struct kern_ipc_perm *ipcp, |
293 | struct ipc_params *params) | ||
286 | { | 294 | { |
287 | if (params->u.nsems > ((struct sem_array *)sma)->sem_nsems) | 295 | struct sem_array *sma; |
296 | |||
297 | sma = container_of(ipcp, struct sem_array, sem_perm); | ||
298 | if (params->u.nsems > sma->sem_nsems) | ||
288 | return -EINVAL; | 299 | return -EINVAL; |
289 | 300 | ||
290 | return 0; | 301 | return 0; |