Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp871385ybl; Wed, 28 Aug 2019 06:34:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxycOLYlAph/49HRrjEMwSQx++D4QuQe5+u/2trvR3HcyivUjbqh3dWvBujcC08skb3QbWb X-Received: by 2002:a62:cd45:: with SMTP id o66mr4816354pfg.112.1566999276009; Wed, 28 Aug 2019 06:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566999276; cv=none; d=google.com; s=arc-20160816; b=Q2NBoTaQTPIdx2bkv38vmUR9SWuotTkr34jAlODNArj1AiDqFSXO9s4xGeccmUuntX Hldqm+L8e1VGOXgweGQ1AonIpsHnLelSFWoLJkVDf77qFuM7Ye899Y/r4X07tVIku1rc KG4NSHebeiar/nIpCoKHWB3JkOdoS+WMO5h8+9LvftQHusmftfzADYEyKg2e8qED4lgk tbDU+Uy91maK3ZkycvrVUwq9+50U+57PUXOPnA5V9/EYES3tCOS5TPJRY/Qpj9dcU3fO 8rY1ETJyNNSPEZ22rgouaDEyS5gKoe+fwpqEIfkHHdwVFromamW8CebBqBXGBJVP9BK0 hpxw== 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=Z/iwyChIHaytlF3nBMrrV8GH07zAorOvTXTDzjkWMC4=; b=yNzRg6UZgPEDpEcDxTaMXscTdT3aQ/r2j4Y2pqGSvh96vlLIKLzRF5tlPHRuecLBIg VIFg4YFJ97Pbl7g7QnqP1bi8ZJ9z7ZX2X5yAXIoB6cvwvJxMPnIJBYSd6zc70rCGQct2 m8LKO+eqBk24n0maqzUpmVmCM+3uVRfl+7y2//3v2crN+TdeQnd9VsyC/RcxFIoMSP5G n+iprhcuXOfwZEW6+cMx46af1NoO5GWVT+MI2CD39DZXC7XcvhdNvEWBC/Zf66xP42rH 1DkSv6jtOrfl/GlUk1lqmg1vT5ven/sCbGSKy87Y80B9jxjOBsLlYNf7wlrH4BLzxAL6 nZ9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si1939904plt.13.2019.08.28.06.34.20; Wed, 28 Aug 2019 06:34:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbfH1Nd1 (ORCPT + 99 others); Wed, 28 Aug 2019 09:33:27 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34168 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbfH1Nd1 (ORCPT ); Wed, 28 Aug 2019 09:33:27 -0400 Received: by mail-wr1-f65.google.com with SMTP id s18so2560135wrn.1 for ; Wed, 28 Aug 2019 06:33:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z/iwyChIHaytlF3nBMrrV8GH07zAorOvTXTDzjkWMC4=; b=mhLHONtENkVUYEfUmrEnjk8JxVjeeql6Q3rk8lvSJI42jqOuwHk6HVWtVUrR1oPYPy 0Lv5/g/tNMVPshdsnGZyjQZscUuFco1h+DQMCXGoxKrmXka9LxhWFwD4N0FrKGOVrhsp EAXqUVMs1e7LZeyc4U8xNGkTybqM+4M92IbWLVuW4q4ZFrEuMJbEtKOz3ZNgfEIO230u pEcAKnzNimPCrV5y/iSbULy2VYCLKhLwHpyyP5hx1iaEQlvXxsQ53xpOyisfdYBSornw gMJJ+jS/EiTD5dINcJZTx4ZaXb8cYRTNuQi+tfM06TjJ8x+qjL0HyLawPzg/Kk6C+0OB chOg== X-Gm-Message-State: APjAAAWUijSxB5cv/56HYoN5hJ+HySjJb74VracMoN5l1TK/ezUQAE7N rsZaAGv3ffHcwk+x80s+3Cs7G54I1Gc= X-Received: by 2002:adf:facc:: with SMTP id a12mr4728967wrs.205.1566999205347; Wed, 28 Aug 2019 06:33:25 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id l62sm4848942wml.13.2019.08.28.06.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 06:33:24 -0700 (PDT) From: Denis Efremov To: Andy Whitcroft , Joe Perches Cc: Denis Efremov , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH v2] checkpatch: check for nested unlikely calls Date: Wed, 28 Aug 2019 16:32:56 +0300 Message-Id: <20190828133256.13630-1-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190827165515.21668-1-efremov@linux.com> References: <20190827165515.21668-1-efremov@linux.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org IS_ERR, IS_ERR_OR_NULL, IS_ERR_VALUE already contain unlikely optimization internally. Thus, there is no point in calling these functions under likely/unlikely. This check is based on the coccinelle rule developed by Enrico Weigelt https://lore.kernel.org/lkml/1559767582-11081-1-git-send-email-info@metux.net/ Signed-off-by: Denis Efremov --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 93a7edfe0f05..55b90e1334d2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6480,6 +6480,12 @@ sub process { "Using $1 should generally have parentheses around the comparison\n" . $herecurr); } +# nested likely/unlikely calls + if ($line =~ /\b(?:(?:un)?likely)\s*\(!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?)/) { + WARN("LIKELY_MISUSE", + "nested (un)?likely calls, unlikely already used in $1 internally\n" . $herecurr); + } + # whine mightly about in_atomic if ($line =~ /\bin_atomic\s*\(/) { if ($realfile =~ m@^drivers/@) { -- 2.21.0