mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@collabora.com>
To: linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org
Cc: mingo@redhat.com, dvhart@infradead.org, kernel@collabora.com,
	krisman@collabora.com,
	"André Almeida" <andrealmeid@collabora.com>
Subject: [RESEND PATCH 4/4] futex: Consistently use fshared as boolean
Date: Thu,  2 Jul 2020 17:28:43 -0300	[thread overview]
Message-ID: <20200702202843.520764-5-andrealmeid@collabora.com> (raw)
In-Reply-To: <20200702202843.520764-1-andrealmeid@collabora.com>

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@collabora.com>
---
 kernel/futex.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 697835ad5bff..d56c9310d734 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -458,7 +458,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)
@@ -483,7 +483,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;
@@ -520,7 +521,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);
@@ -608,7 +609,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.27.0


  parent reply	other threads:[~2020-07-02 20:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 20:28 [RESEND PATCH 0/4] futex: Minor code improvements André Almeida
2020-07-02 20:28 ` [RESEND PATCH 1/4] futex: Remove put_futex_key() André Almeida
2020-07-17 22:01   ` [tip: locking/core] " tip-bot2 for André Almeida
2020-07-02 20:28 ` [RESEND PATCH 2/4] futex: Remove needless goto's André Almeida
2020-07-17 22:01   ` [tip: locking/core] " tip-bot2 for André Almeida
2020-07-02 20:28 ` [RESEND PATCH 3/4] futex: Remove unused or redundant includes André Almeida
2020-07-17 21:46   ` Thomas Gleixner
2020-07-17 22:39     ` André Almeida
2020-07-18  0:02       ` Thomas Gleixner
2020-07-17 22:01   ` [tip: locking/core] " tip-bot2 for André Almeida
2020-07-18  0:01   ` tip-bot2 for André Almeida
2020-07-02 20:28 ` André Almeida [this message]
2020-07-17 22:01   ` [tip: locking/core] futex: Consistently use fshared as boolean tip-bot2 for André Almeida
2020-07-18  0:01   ` tip-bot2 for André Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200702202843.520764-5-andrealmeid@collabora.com \
    --to=andrealmeid@collabora.com \
    --cc=dvhart@infradead.org \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®