Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2659500pxb; Tue, 23 Feb 2021 12:13:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzF29Nh1Gfp8V67CwFXlXhFP+F94gSyuehyhHbxB2xChXf9EPf+KlxRJMfhwBLxk8ibRvL/ X-Received: by 2002:a17:906:fa01:: with SMTP id lo1mr23824821ejb.268.1614111208775; Tue, 23 Feb 2021 12:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614111208; cv=none; d=google.com; s=arc-20160816; b=GCXVKahR1HaCkFf0p2IVBeVK/e75O6VUg9o/y0VIIfTr4qnnyJhgwpqCPUqulaOfKU TDgUz7NTru6VqGM0Vg5lgBgyUy0w+qPMizmK9xJeynuMbozUwXSg5U6By429BcmVPbP0 faJIgKipblryE0PlLnYEbP2JOeBOGS8TRHrbAQzFs5o0VuobAsIP6ASs7I7ijFoJ+YKV yCX9RN+TEhCE5IX/EAP3o0wBSEcb0ZGnMuiLRv2dSXqmqUOWj+IjNFSHrL9ovJ1axW1z ZUQBgjodT5exT16PS8L0vEQ9kSeM7au3E09J86Um7Jc48ZuBwaO7A1iGKSPB5Bz1EOh3 OefA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=CQEfesAGh6Yaxupcr8w3bDyhXlptt6J3Yf5vNzEZ7xI=; b=cSKOU10zGUx5AWF9JW/Vrbg0zTvIuzA6axuP+C1/nsYQfc8kG7Ox2xOd+Pbwa4Egw9 S8qKPMPd1JAX89xPb1lQb+4gB8Z4eMo0XABVgQ1MR6ao4Z791ilD08qcR/fYFH5smpdf 6tdOPc2irUDYhWTGDBqkqEND+j/4eUPoRg8khmq2yvwKxvuklhRoIFlByoxqsYZKFHQx KjzOpC2LxHE422Ln7GxSd3noipFEwXGxQrETNdenX/UZKUkwE/tPvVGiSAQ7Km9O5U7+ 049tXbcb2KF5rsTWBUuszIBCfsmOwXxO8/aRDHPPUVCboKBc889WjPVcjxXZc2aueKE/ C+tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ahJMz/9Q"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si14190696ejf.443.2021.02.23.12.13.04; Tue, 23 Feb 2021 12:13:28 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b="ahJMz/9Q"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233191AbhBWP65 (ORCPT + 99 others); Tue, 23 Feb 2021 10:58:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233309AbhBWP6s (ORCPT ); Tue, 23 Feb 2021 10:58:48 -0500 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3C0C06174A for ; Tue, 23 Feb 2021 07:58:06 -0800 (PST) Received: by mail-wr1-x44a.google.com with SMTP id e11so7421432wro.19 for ; Tue, 23 Feb 2021 07:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=CQEfesAGh6Yaxupcr8w3bDyhXlptt6J3Yf5vNzEZ7xI=; b=ahJMz/9QD//FktmI3FiYI5kZv2HmCwtxm6T0qpp83ZVG11ijWrwdYwZhWhlWBJ+CEk 1jnG0OcblYWp0DVJ2dRRxnnLq+pq/xlYOWPblGlAnVTe4mmpgGKdY6ht57WvK4H62vTB CGC8mOl2P3AhVSh0z/+sXRUnjWeANK35861+rdXPjXd7vpwV2nV7e4gUfGh750HKKDJX r78EbvODYloUoicbFLZE55MmD1KVG5MrrSLwvm8nefA6P2EJdhqCH+x+jCmeDqeLQ68e oDb0F8nFaTaHd77uYGBKUBqhEv8gIzKcfslPSAY4HgpmgTHHKG5egD0k3uoCse1RY+Nw ZaVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CQEfesAGh6Yaxupcr8w3bDyhXlptt6J3Yf5vNzEZ7xI=; b=GDAKro2zt7SE7yW4n1BBn63KzaEEx7peDb7YicQ8BOHqnALsTNZfPk2iX3CVzWF9we p9+KcnR/ebjRgCpBgkNou+DC2Ii+NOTNJGlWQhH59wK9Lcb7KWwqhh2bOEHKhvSLMlOk k05M7ypqJMi4SmixHyAvRNcOweQIv7RKdsO2G5mBj6AhC886XJxWhlO1bdz3KIaXvyGa yqy+fV1YffqJWcDhmezWZTPXja6coiarDNHQ9S7e20EWAhNnyko7vyhQXxjjaUU0mjdo 8nEqc6W+xHXgSATGfgr0IXDx+Gw4gKlJKHb7lzg8vqItB6YZ/DTL1aUQ7sSFv7mecSPa YSIA== X-Gm-Message-State: AOAM531B56TPWuDqbc+suM+FlOl+LaETnL4J1d2R+bUKGzyUB1lmBwt3 H8qJps+uwu62ez/Ijl6r/2MHw+iA3Tg= Sender: "ascull via sendgmr" X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a1c:17:: with SMTP id 23mr216919wma.6.1614095885613; Tue, 23 Feb 2021 07:58:05 -0800 (PST) Date: Tue, 23 Feb 2021 15:57:56 +0000 In-Reply-To: <20210223155759.3495252-1-ascull@google.com> Message-Id: <20210223155759.3495252-2-ascull@google.com> Mime-Version: 1.0 References: <20210223155759.3495252-1-ascull@google.com> X-Mailer: git-send-email 2.30.0.617.g56c4b15f3c-goog Subject: [PATCH v2 1/4] bug: Remove redundant condition check in report_bug From: Andrew Scull To: kvmarm@lists.cs.columbia.edu Cc: linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, julien.thierry.kdev@gmail.com, will@kernel.org, catalin.marinas@arm.com, kernel-team@android.com, Andrew Scull , Peter Zijlstra , "Steven Rostedt (VMware)" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org report_bug() will return early if it cannot find a bug corresponding to the provided address. The subsequent test for the bug will always be true so remove it. Signed-off-by: Andrew Scull Cc: Peter Zijlstra Cc: "Steven Rostedt (VMware)" --- lib/bug.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/bug.c b/lib/bug.c index 7103440c0ee1..4ab398a2de93 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -158,30 +158,27 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) file = NULL; line = 0; - warning = 0; - if (bug) { #ifdef CONFIG_DEBUG_BUGVERBOSE #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS - file = bug->file; + file = bug->file; #else - file = (const char *)bug + bug->file_disp; + file = (const char *)bug + bug->file_disp; #endif - line = bug->line; + line = bug->line; #endif - warning = (bug->flags & BUGFLAG_WARNING) != 0; - once = (bug->flags & BUGFLAG_ONCE) != 0; - done = (bug->flags & BUGFLAG_DONE) != 0; - - if (warning && once) { - if (done) - return BUG_TRAP_TYPE_WARN; - - /* - * Since this is the only store, concurrency is not an issue. - */ - bug->flags |= BUGFLAG_DONE; - } + warning = (bug->flags & BUGFLAG_WARNING) != 0; + once = (bug->flags & BUGFLAG_ONCE) != 0; + done = (bug->flags & BUGFLAG_DONE) != 0; + + if (warning && once) { + if (done) + return BUG_TRAP_TYPE_WARN; + + /* + * Since this is the only store, concurrency is not an issue. + */ + bug->flags |= BUGFLAG_DONE; } /* -- 2.30.0.617.g56c4b15f3c-goog