Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp950030ybm; Wed, 27 May 2020 11:59:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5cexfdYktQvCYkkOKsDW4hEK3LxLUgpAtRDvPg9MCJNM/AZ7azkg8RD4wxXqSF8NtiQe/ X-Received: by 2002:a05:6402:1cad:: with SMTP id cz13mr25780069edb.56.1590605964470; Wed, 27 May 2020 11:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590605964; cv=none; d=google.com; s=arc-20160816; b=TZDX+XWHyXdG08A2dQKl0lUzvUE9ApVnxcunDI5jfM4dYC4hclidsJVpUz9/+bziff RorKfhhZsymhtVEcDzu0kP1qIg+fH93Qss0z+vmOHe/gTZ4cp6CuAtRAtlqQ5YT4lr1g l4YuB2UhtsGoGR6xRpILbKxQ1EqIq6j6vpnzBkPOzjhLm6DIm+OvcRmLf+dScCojN9hB GPeSIe00JVLkPMhO3wjg2f0CTamcWw3MImpnMh+MtBZ5TQj+xsYCMNsCOiexpWgzZE8/ ZHZen0LDrXtwivWHrVjZjpLBjsZkR4ci9bMHh3XksruL4tVWBSZe/67J9DPfhxRRpBW4 XW9w== 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=lBlx77kRy30p2B6ihMyjUp0flM+VgFKF9yDeHs4LzEE=; b=gjU6rfFRVDrlfn+Gl3A+lMcFFBR2nTN464vsxqQWvLAfKkcAN9TsnvWhbiad6ercyM vNif/lWgs4mmeAXku7esRhQoOxwx+C/6gIW48XVRFPy2h2oP01iRZMXRNRyEi84ce6Ca Ubf0tQNHpgiZPDI8ECiXJgoTte9LE3EXgHvLs6AurgQj1hazFLKW4Mwe32gNobBgohMg g3E3LSRyz4ACEf4+POZ7bxaWV1t9Orit/PrjFcS0nmaU4AJ3+O7pGNJhp4ZXtOb2gpHN IrLF+5BlERrcn877Zz9z3bbiwgB3LTsEremvEL0VRv8n3ukL6/rYIXIVn9rGU4DIcuCx 7lJg== 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 b17si2059033eja.150.2020.05.27.11.59.01; Wed, 27 May 2020 11:59:24 -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 S1730516AbgE0PsE (ORCPT + 98 others); Wed, 27 May 2020 11:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgE0PsC (ORCPT ); Wed, 27 May 2020 11:48:02 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A718C05BD1E for ; Wed, 27 May 2020 08:48:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id D2CBC2A3AB1 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 2/4] futex: Remove needless goto's Date: Wed, 27 May 2020 12:47:45 -0300 Message-Id: <20200527154747.36931-3-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 As stated in the coding style documentation[1], "if there is no cleanup needed then just return directly", instead of jumping to a label and then returning. Remove such goto's and replace with a return statement. When there's a ternary operator on the return value, replace with the result of the operation when is logically possible to determine it by the control flow. [1] https://www.kernel.org/doc/html/latest/process/coding-style.html#centralized-exiting-of-functions Signed-off-by: André Almeida --- kernel/futex.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index 1f0287a51dce..ec07de620d1e 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1604,13 +1604,13 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, FUTEX_READ); if (unlikely(ret != 0)) - goto out; + return ret; hb = hash_futex(&key); /* Make sure we really have tasks to wakeup */ if (!hb_waiters_pending(hb)) - goto out; + return ret; spin_lock(&hb->lock); @@ -1633,7 +1633,6 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) spin_unlock(&hb->lock); wake_up_q(&wake_q); -out: return ret; } @@ -1700,10 +1699,10 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, retry: ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, FUTEX_READ); if (unlikely(ret != 0)) - goto out; + return ret; ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, FUTEX_WRITE); if (unlikely(ret != 0)) - goto out; + return ret; hb1 = hash_futex(&key1); hb2 = hash_futex(&key2); @@ -1721,13 +1720,13 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, * an MMU, but we might get them from range checking */ ret = op_ret; - goto out; + return ret; } if (op_ret == -EFAULT) { ret = fault_in_user_writeable(uaddr2); if (ret) - goto out; + return ret; } if (!(flags & FLAGS_SHARED)) { @@ -1770,7 +1769,6 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, out_unlock: double_unlock_hb(hb1, hb2); wake_up_q(&wake_q); -out: return ret; } @@ -1977,20 +1975,18 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, retry: ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, FUTEX_READ); if (unlikely(ret != 0)) - goto out; + return ret; ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, requeue_pi ? FUTEX_WRITE : FUTEX_READ); if (unlikely(ret != 0)) - goto out; + return ret; /* * The check above which compares uaddrs is not sufficient for * shared futexes. We need to compare the keys: */ - if (requeue_pi && match_futex(&key1, &key2)) { - ret = -EINVAL; - goto out; - } + if (requeue_pi && match_futex(&key1, &key2)) + return -EINVAL; hb1 = hash_futex(&key1); hb2 = hash_futex(&key2); @@ -2010,7 +2006,7 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, ret = get_user(curval, uaddr1); if (ret) - goto out; + return ret; if (!(flags & FLAGS_SHARED)) goto retry_private; @@ -2076,7 +2072,7 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, ret = fault_in_user_writeable(uaddr2); if (!ret) goto retry; - goto out; + return ret; case -EBUSY: case -EAGAIN: /* @@ -2195,8 +2191,6 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, double_unlock_hb(hb1, hb2); wake_up_q(&wake_q); hb_waiters_dec(hb2); - -out: return ret ? ret : task_count; } @@ -2542,7 +2536,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) */ if (q->pi_state->owner != current) ret = fixup_pi_state_owner(uaddr, q, current); - goto out; + return ret ? ret : locked; } /* @@ -2555,7 +2549,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) */ if (q->pi_state->owner == current) { ret = fixup_pi_state_owner(uaddr, q, NULL); - goto out; + return ret; } /* @@ -2569,8 +2563,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) q->pi_state->owner); } -out: - return ret ? ret : locked; + return ret; } /** @@ -2667,7 +2660,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags, ret = get_user(uval, uaddr); if (ret) - goto out; + return ret; if (!(flags & FLAGS_SHARED)) goto retry_private; @@ -2680,7 +2673,6 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags, ret = -EWOULDBLOCK; } -out: return ret; } -- 2.26.2