summaryrefslogtreecommitdiffstats
path: root/ipc/sem.c
diff options
context:
space:
mode:
authorNadia Derbey <Nadia.Derbey@bull.net>2007-10-18 23:40:51 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 11:53:46 -0700
commit03f02c7657f7948ab980280c54c9366f962b1474 (patch)
tree7b1f564772077db0aed1e3c5a79ae77d2c1d2307 /ipc/sem.c
parent023a53557ea0e987b002e9a844242ef0b0aa1eb3 (diff)
downloadlinux-03f02c7657f7948ab980280c54c9366f962b1474.tar.gz
linux-03f02c7657f7948ab980280c54c9366f962b1474.tar.bz2
linux-03f02c7657f7948ab980280c54c9366f962b1474.zip
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)
static inline struct sem_array *sem_lock(struct ipc_namespace *ns, int id)
{
- return (struct sem_array *) ipc_lock(&sem_ids(ns), id);
+ struct kern_ipc_perm *ipcp = ipc_lock(&sem_ids(ns), id);
+
+ return container_of(ipcp, struct sem_array, sem_perm);
}
static inline struct sem_array *sem_lock_check(struct ipc_namespace *ns,
int id)
{
- return (struct sem_array *) ipc_lock_check(&sem_ids(ns), id);
+ struct kern_ipc_perm *ipcp = ipc_lock_check(&sem_ids(ns), id);
+
+ return container_of(ipcp, struct sem_array, sem_perm);
}
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)
}
-static inline int sem_security(void *sma, int semflg)
+static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg)
{
- return security_sem_associate((struct sem_array *) sma, semflg);
+ struct sem_array *sma;
+
+ sma = container_of(ipcp, struct sem_array, sem_perm);
+ return security_sem_associate(sma, semflg);
}
-static inline int sem_more_checks(void *sma, struct ipc_params *params)
+static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
+ struct ipc_params *params)
{
- if (params->u.nsems > ((struct sem_array *)sma)->sem_nsems)
+ struct sem_array *sma;
+
+ sma = container_of(ipcp, struct sem_array, sem_perm);
+ if (params->u.nsems > sma->sem_nsems)
return -EINVAL;
return 0;