Skip to content

Commit ce621f5

Browse files
Nadia DerbeyLinus Torvalds
authored andcommitted
ipc: introduce the ipcid_to_idx macro
This is a trivial patch that changes all the (id % SEQ_MULTIPLIER) into a call to the ipcid_to_idx(id) macro. 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>
1 parent 03f02c7 commit ce621f5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎ipc/util.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
413413

414414
void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
415415
{
416-
int lid = ipcp->id % SEQ_MULTIPLIER;
416+
int lid = ipcid_to_idx(ipcp->id);
417417

418418
idr_remove(&ids->ipcs_idr, lid);
419419

@@ -672,7 +672,7 @@ void ipc64_perm_to_ipc_perm (struct ipc64_perm *in, struct ipc_perm *out)
672672
struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
673673
{
674674
struct kern_ipc_perm *out;
675-
int lid = id % SEQ_MULTIPLIER;
675+
int lid = ipcid_to_idx(id);
676676

677677
rcu_read_lock();
678678
out = idr_find(&ids->ipcs_idr, lid);

‎ipc/util.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
7979
#define IPC_MSG_IDS 1
8080
#define IPC_SHM_IDS 2
8181

82+
#define ipcid_to_idx(id) ((id) % SEQ_MULTIPLIER)
83+
8284
/* must be called with ids->mutex acquired.*/
8385
int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int);
8486
int ipc_get_maxid(struct ipc_ids *);

0 commit comments

Comments
 (0)