Skip to content

Commit 9261308

Browse files
andrealmeidKAGA-KOKO
authored andcommitted
futex: Consistently use fshared as boolean
Since fshared is only conveying true/false values, declare it as bool. In get_futex_key() the usage of fshared can be restricted to the first part of the function. If fshared is false the function is terminated early and the subsequent code can use a constant 'true' instead of the variable. Signed-off-by: André Almeida <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d7c5ed7 commit 9261308

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kernel/futex.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static u64 get_inode_sequence_number(struct inode *inode)
476476
/**
477477
* get_futex_key() - Get parameters which are the keys for a futex
478478
* @uaddr: virtual address of the futex
479-
* @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED
479+
* @fshared: false for a PROCESS_PRIVATE futex, true for PROCESS_SHARED
480480
* @key: address where result is stored.
481481
* @rw: mapping needs to be read/write (values: FUTEX_READ,
482482
* FUTEX_WRITE)
@@ -500,8 +500,8 @@ static u64 get_inode_sequence_number(struct inode *inode)
500500
*
501501
* lock_page() might sleep, the caller should not hold a spinlock.
502502
*/
503-
static int
504-
get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, enum futex_access rw)
503+
static int get_futex_key(u32 __user *uaddr, bool fshared, union futex_key *key,
504+
enum futex_access rw)
505505
{
506506
unsigned long address = (unsigned long)uaddr;
507507
struct mm_struct *mm = current->mm;
@@ -538,7 +538,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, enum futex_a
538538

539539
again:
540540
/* Ignore any VERIFY_READ mapping (futex common case) */
541-
if (unlikely(should_fail_futex(fshared)))
541+
if (unlikely(should_fail_futex(true)))
542542
return -EFAULT;
543543

544544
err = get_user_pages_fast(address, 1, FOLL_WRITE, &page);
@@ -626,7 +626,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, enum futex_a
626626
* A RO anonymous page will never change and thus doesn't make
627627
* sense for futex operations.
628628
*/
629-
if (unlikely(should_fail_futex(fshared)) || ro) {
629+
if (unlikely(should_fail_futex(true)) || ro) {
630630
err = -EFAULT;
631631
goto out;
632632
}

0 commit comments

Comments
 (0)