Skip to content

Commit

Permalink
ipc: change kern_ipc_perm.deleted type to bool
Browse files Browse the repository at this point in the history
struct kern_ipc_perm.deleted is meant to be used as a boolean toggle, and
the changes introduced by this patch are just to make the case explicit.

Signed-off-by: Rafael Aquini <[email protected]>
Reviewed-by: Rik van Riel <[email protected]>
Cc: Greg Thelen <[email protected]>
Acked-by: Davidlohr Bueso <[email protected]>
Cc: Manfred Spraul <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
aquini authored and torvalds committed Jan 28, 2014
1 parent 0f3d2b0 commit 72a8ff2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/linux/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
struct kern_ipc_perm
{
spinlock_t lock;
int deleted;
bool deleted;
int id;
key_t key;
kuid_t uid;
Expand Down
2 changes: 1 addition & 1 deletion ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ static inline struct sem_array *sem_obtain_lock(struct ipc_namespace *ns,
/* ipc_rmid() may have already freed the ID while sem_lock
* was spinning: verify that the structure is still valid
*/
if (!ipcp->deleted)
if (ipc_valid_object(ipcp))
return container_of(ipcp, struct sem_array, sem_perm);

sem_unlock(sma, *locknum);
Expand Down
6 changes: 3 additions & 3 deletions ipc/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
idr_preload(GFP_KERNEL);

spin_lock_init(&new->lock);
new->deleted = 0;
new->deleted = false;
rcu_read_lock();
spin_lock(&new->lock);

Expand Down Expand Up @@ -447,7 +447,7 @@ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)

ids->in_use--;

ipcp->deleted = 1;
ipcp->deleted = true;

return;
}
Expand Down Expand Up @@ -657,7 +657,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
/* ipc_rmid() may have already freed the ID while ipc_lock
* was spinning: here verify that the structure is still valid
*/
if (!out->deleted)
if (ipc_valid_object(out))
return out;

spin_unlock(&out->lock);
Expand Down
2 changes: 1 addition & 1 deletion ipc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static inline void ipc_unlock(struct kern_ipc_perm *perm)
*/
static inline bool ipc_valid_object(struct kern_ipc_perm *perm)
{
return perm->deleted == 0;
return !perm->deleted;
}

struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id);
Expand Down

0 comments on commit 72a8ff2

Please sign in to comment.