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/shm.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/shm.c')
-rw-r--r-- | ipc/shm.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -139,13 +139,17 @@ void __init shm_init (void) | |||
139 | 139 | ||
140 | static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id) | 140 | static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id) |
141 | { | 141 | { |
142 | return (struct shmid_kernel *) ipc_lock(&shm_ids(ns), id); | 142 | struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id); |
143 | |||
144 | return container_of(ipcp, struct shmid_kernel, shm_perm); | ||
143 | } | 145 | } |
144 | 146 | ||
145 | static inline struct shmid_kernel *shm_lock_check(struct ipc_namespace *ns, | 147 | static inline struct shmid_kernel *shm_lock_check(struct ipc_namespace *ns, |
146 | int id) | 148 | int id) |
147 | { | 149 | { |
148 | return (struct shmid_kernel *) ipc_lock_check(&shm_ids(ns), id); | 150 | struct kern_ipc_perm *ipcp = ipc_lock_check(&shm_ids(ns), id); |
151 | |||
152 | return container_of(ipcp, struct shmid_kernel, shm_perm); | ||
149 | } | 153 | } |
150 | 154 | ||
151 | static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s) | 155 | static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s) |
@@ -424,14 +428,21 @@ no_file: | |||
424 | return error; | 428 | return error; |
425 | } | 429 | } |
426 | 430 | ||
427 | static inline int shm_security(void *shp, int shmflg) | 431 | static inline int shm_security(struct kern_ipc_perm *ipcp, int shmflg) |
428 | { | 432 | { |
429 | return security_shm_associate((struct shmid_kernel *) shp, shmflg); | 433 | struct shmid_kernel *shp; |
434 | |||
435 | shp = container_of(ipcp, struct shmid_kernel, shm_perm); | ||
436 | return security_shm_associate(shp, shmflg); | ||
430 | } | 437 | } |
431 | 438 | ||
432 | static inline int shm_more_checks(void *shp, struct ipc_params *params) | 439 | static inline int shm_more_checks(struct kern_ipc_perm *ipcp, |
440 | struct ipc_params *params) | ||
433 | { | 441 | { |
434 | if (((struct shmid_kernel *)shp)->shm_segsz < params->u.size) | 442 | struct shmid_kernel *shp; |
443 | |||
444 | shp = container_of(ipcp, struct shmid_kernel, shm_perm); | ||
445 | if (shp->shm_segsz < params->u.size) | ||
435 | return -EINVAL; | 446 | return -EINVAL; |
436 | 447 | ||
437 | return 0; | 448 | return 0; |