ipc: change kern_ipc_perm.deleted type to bool
authorRafael Aquini <aquini@redhat.com>
Tue, 28 Jan 2014 01:07:02 +0000 (17:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Jan 2014 05:02:39 +0000 (21:02 -0800)
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 <aquini@redhat.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Greg Thelen <gthelen@google.com>
Acked-by: Davidlohr Bueso <davidlohr@hp.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/ipc.h
ipc/sem.c
ipc/util.c
ipc/util.h

index 8d861b2651f7b0586edfa0be89adac92d9592746..9d84942ae2e577835a338b8a352f9c93eabe148b 100644 (file)
@@ -11,7 +11,7 @@
 struct kern_ipc_perm
 {
        spinlock_t      lock;
-       int             deleted;
+       bool            deleted;
        int             id;
        key_t           key;
        kuid_t          uid;
index 4d88194a5ffe74dbf02deaba02aca46c6098a140..160fbb3390bb2f2efd059357cfd9f9dac34fec3d 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -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);
index 3ae17a4ace5b9ba242fd1aa42543d64145e5cb7f..9dc67fa4308c7d006823788c0d7379558cc9a3de 100644 (file)
@@ -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);
 
@@ -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;
 }
@@ -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);
index d05b7085a8871810e8696ce9929b6b56b0a57658..a1cbc3aaf25af92f7378a569effd92b808995f38 100644 (file)
@@ -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);