aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/sem.c
diff options
context:
space:
mode:
authorNadia Derbey <Nadia.Derbey@bull.net>2007-10-19 02:40:51 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:46 -0400
commit03f02c7657f7948ab980280c54c9366f962b1474 (patch)
tree7b1f564772077db0aed1e3c5a79ae77d2c1d2307 /ipc/sem.c
parent023a53557ea0e987b002e9a844242ef0b0aa1eb3 (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.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index 673d63da52c6..446c8f518045 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -176,13 +176,17 @@ void __init sem_init (void)
176 176
177static inline struct sem_array *sem_lock(struct ipc_namespace *ns, int id) 177static 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
182static inline struct sem_array *sem_lock_check(struct ipc_namespace *ns, 184static 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
188static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) 192static 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
280static inline int sem_security(void *sma, int semflg) 284static 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
285static inline int sem_more_checks(void *sma, struct ipc_params *params) 292static 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;