Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp950057ybm; Wed, 27 May 2020 11:59:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytO8ZJfSZJYao/nU27qIrDiAQSusCdE1Gv+67iXaHqIhi/aCbdy/2WsS+0v9YaMMX7vrP1 X-Received: by 2002:a05:6402:b0b:: with SMTP id bm11mr26209244edb.92.1590605967463; Wed, 27 May 2020 11:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590605967; cv=none; d=google.com; s=arc-20160816; b=Q8LPy2pWK9m09PxykJ2ojS3lG2kzEiIEr6ZenUC6CFtS2zpzR1Cu1QYUsmXgX0ZgLe +7+Ya2URV8kCJEjtUMPrRhTP+e5NxbWjJVBwZJP6IS/Ds3BVMyc01gltCzVNoPH0YYRW CjTZuCh4Z4j2gtHADhD12U2oA51WsmdTiTmLxgBCrlMqEGiplpsnMycfzwTVPeCXsQ3B rPtZDwCTm0EV4BVhcSkQQpN3IpzM0m9QNpP2C1AcUdXJG4aexti9ItiJJEJ6GI48Bsur jt7dKM4QmEKeMtSuQ9CU0OfEPgleA9hPj/ajnRhpUMw7dHzGar0P/WpgMwBQ6KliO4QU 2BKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=c/v1V396aKt6VwKU6ckX2kpfv24SLMaYDuDFViEQT6Q=; b=VMePxeHUmxNKzpcjAPzH/Mjjpjgm2UIYKsvI+dgu9RN7nrah1dPx0n93N4BlvHXVgg 3VOJvYq6W/LwBPxKzsNoxWa5ulSBFg0XMEeGXDoRtpjWzq4Vv5sds1CBBEonbY05zfgS Ri4mWuvA/ZwqlqNuqcf7ymZ373B+vGgFVlo1kNokhyckyV9Kl2KAwOjkg4gCzppirfvr ibi7+KUrDWOtZQVyuHvtuksdazMbpc2Y3OYi4DsBor+lx6reNDAgmEulmnRiV257vbhl tNfu4tzx1av6xZUlWYLo8XO9hDCMvsSUKNBYUiY+YNikwzYSi2qnteZeWc7tzrJtISM1 s5HQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y21si2272226edt.501.2020.05.27.11.59.04; Wed, 27 May 2020 11:59:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390024AbgE0PsK (ORCPT + 98 others); Wed, 27 May 2020 11:48:10 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44218 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgE0PsJ (ORCPT ); Wed, 27 May 2020 11:48:09 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id BBFFF2A3AC0 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= 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, =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH 4/4] futex: Consistently use fshared as boolean Date: Wed, 27 May 2020 12:47:47 -0300 Message-Id: <20200527154747.36931-5-andrealmeid@collabora.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200527154747.36931-1-andrealmeid@collabora.com> References: <20200527154747.36931-1-andrealmeid@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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