[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20200527154747.36931-5-andrealmeid@collabora.com>
Date: Wed, 27 May 2020 12:47:47 -0300
From: André Almeida <andrealmeid@...labora.com>
To: linux-kernel@...r.kernel.org, tglx@...utronix.de,
peterz@...radead.org
Cc: mingo@...hat.com, dvhart@...radead.org, kernel@...labora.com,
krisman@...labora.com,
André Almeida <andrealmeid@...labora.com>
Subject: [PATCH 4/4] futex: Consistently use fshared as boolean
Since fshared is meant to true/false values, declare it as bool. If the
code ever reaches the code beneath again label, we are sure that the
futex is shared, so we can use the true value instead of the variable.
Signed-off-by: André Almeida <andrealmeid@...labora.com>
---
kernel/futex.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index 7bc5340396aa..a04f3793114f 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -457,7 +457,7 @@ static u64 get_inode_sequence_number(struct inode *inode)
/**
* get_futex_key() - Get parameters which are the keys for a futex
* @uaddr: virtual address of the futex
- * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED
+ * @fshared: false for a PROCESS_PRIVATE futex, true for PROCESS_SHARED
* @key: address where result is stored.
* @rw: mapping needs to be read/write (values: FUTEX_READ,
* FUTEX_WRITE)
@@ -479,7 +479,8 @@ static u64 get_inode_sequence_number(struct inode *inode)
* lock_page() might sleep, the caller should not hold a spinlock.
*/
static int
-get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, enum futex_access rw)
+get_futex_key(u32 __user *uaddr, bool fshared, union futex_key *key,
+ enum futex_access rw)
{
unsigned long address = (unsigned long)uaddr;
struct mm_struct *mm = current->mm;
@@ -516,7 +517,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, enum futex_a
again:
/* Ignore any VERIFY_READ mapping (futex common case) */
- if (unlikely(should_fail_futex(fshared)))
+ if (unlikely(should_fail_futex(true)))
return -EFAULT;
err = get_user_pages_fast(address, 1, FOLL_WRITE, &page);
@@ -604,7 +605,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, enum futex_a
* A RO anonymous page will never change and thus doesn't make
* sense for futex operations.
*/
- if (unlikely(should_fail_futex(fshared)) || ro) {
+ if (unlikely(should_fail_futex(true)) || ro) {
err = -EFAULT;
goto out;
}
--
2.26.2
Powered by blists - more mailing lists