Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp988542pxj; Thu, 27 May 2021 17:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3M6sskZuaekhtqBz4PLTqIPETe1tkU/X3HJiTkG+DZZJgOVOYyxdJaMbFuLMsnxoWHsA1 X-Received: by 2002:aa7:c9ce:: with SMTP id i14mr6966409edt.148.1622160472633; Thu, 27 May 2021 17:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622160472; cv=none; d=google.com; s=arc-20160816; b=kA6YaVzVszJrJTVXUOjAybSQnerRE0eWsIjJnfa+2Gu3nRQ92QZCe2eig+8j1bPPKm okj52O5uYwg03uRbh2rALZj/RhVlDsCV72SzZGhLk2cIqVHTzp7yBb2UEPDd8BP6YXHi ITP7y5CBCKKagRkI/uNKXb2EkFh8jstvzFfKr0aFXgXjr8lpXpFcH1cFVKNjFmAGR6r0 RFx+fKfgK5k+KaqvYL+WgFhr+Wl+PhDpBnVTxcy6q/icYvqx7bD0R65vMGPW+PdJ6SE2 Qhob71B7iTcrZEgvx3oASOtDg4VE34g2EQAdXmsMpAGuTecFD8Ia+Xi4izDTIMx9Uil/ K40A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=c8610SbT0epVJTQqY9Ri5rpbvG7EHYsiNE4dwA9QJjw=; b=F/QolPPme5RX6gTicQOVwhsJLt/yHUqX0ygQXRPFKl0NOvgKUVBBFBsJpXty32XwMa O2BNrC1xlm+wU6zC4XhXSQ6tA6BujLn0lchpge8wfBUTHs0E39OdJ7xrCuupN09zQYOv +9xEy5T/c/8O8Z8rFthVQX8Bx4kLT60BiY7Q4E/SJ4y1D7257TfPipcZ8JH8bm6GmTTV 0jh9DJYWx1r51/9Qg3y/UE0c4KIxii7QHKoRlpb3C1JoDYbEQrxQHOqyNXO5HZbFsZXl nxXiAmpr94Tw54af5NFO5wBLmiWxGpaOSVpnuYQpt0OBvjrOATd7HN687TkzIG11IC8J BmJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hNShJ9Wa; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si3553328ejp.735.2021.05.27.17.07.29; Thu, 27 May 2021 17:07:52 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hNShJ9Wa; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234633AbhE0VtY (ORCPT + 99 others); Thu, 27 May 2021 17:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbhE0VtX (ORCPT ); Thu, 27 May 2021 17:49:23 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5158C061574 for ; Thu, 27 May 2021 14:47:47 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id n17-20020a7bc5d10000b0290169edfadac9so3445070wmk.1 for ; Thu, 27 May 2021 14:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=c8610SbT0epVJTQqY9Ri5rpbvG7EHYsiNE4dwA9QJjw=; b=hNShJ9WaRhPwbYFUC6iY9J4S0KDOFrfH8Jx06xdeLWvO5Bh8hj+sjy7HJlG3IhNo5C SPh4vkU/2m8gN1HRbswSueFZGQyGuR2U5UbU4Eg3dwRPk7+kQSEG+lzG2x6naVtIbBQe sf6StgpQ0OaQwlRu8yhhascwjpbMwfJ805jFyEoXArpsoWRtQAe7uSMPvzUsqSNLqQLP Li9j21NrHZtUy4JOklRXW+0rdqIw9i4cmDTr7nbamMrrUsbabcWf82HegkH3pgcEsWqZ coV8Q53DzWC2B40gMnyhHclVFQ2gocSGYI9xm0s5iSI0Ayn6h71bLXDNfrwm77coAkSU WfUw== 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:mime-version :content-transfer-encoding; bh=c8610SbT0epVJTQqY9Ri5rpbvG7EHYsiNE4dwA9QJjw=; b=M2AAZNMWA4WJAbOzVTr8STv96wljBKh9wm3Qc/6QowQ8PI8g0TmCl6fADLlHYXO9uI uzKqrnZuw3PzQIOmfHkoUHv/Gm7epVTD3Y21+Oi17t10sNSmgJMkvCV4PyAM8JpGhIk5 E/qp2SALWD322a3+vRhbzzpLTWwYdL2WTjFjG37+G/+oFZqHI5uaWCrI/j6m79VP1D29 i1g0RgRIJiFz0LY0OnLIFwBkcdhxAPHEksoe0YEGpmn5zYrUO8FAJX7b74EW0X4DuWiZ hDyA1k32/aszOsS2e5icT7Gh0eiuhn6LRpwI4Ke2XMKMw46GZX7phnjLYAiF1iIUGdrE Gjpg== X-Gm-Message-State: AOAM532KpS+hr1OLCszAYbsYi0abd+AR4u7sHa8s9GyokyEPGkqZcaFp UsFQMVKDLpXhfEbA9gAM4K4= X-Received: by 2002:a1c:f212:: with SMTP id s18mr10131194wmc.172.1622152066518; Thu, 27 May 2021 14:47:46 -0700 (PDT) Received: from lshz10676.. ([88.123.50.136]) by smtp.gmail.com with ESMTPSA id h1sm12571903wmq.0.2021.05.27.14.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 14:47:46 -0700 (PDT) From: Antonio Borneo To: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn Cc: Antonio Borneo , linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: fix incorrect camelcase detection on numeric constant Date: Thu, 27 May 2021 23:47:41 +0200 Message-Id: <20210527214741.180449-1-borneo.antonio@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code fragment below int foo(int *array, int index) { return array[index & 0xFF]; } triggers an incorrect camelcase detection by checking a subset of the hex constant: CHECK: Avoid CamelCase: #3: FILE: test.c:3: + return array[index & 0xFF]; This is caused by passing the whole string "array[index & 0xFF]" to the inner loop that iterates over a "$Ident" match. With no check to exclude a constant, the match iterates over "array", "index" and "xFF", thus the camelcase detection. Similar issue can be detected with other constants like "1uL", "0xffffU". Force the match to start at word boundary so the constants will be filtered-out. Signed-off-by: Antonio Borneo --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) To: Andy Whitcroft To: Joe Perches To: Dwaipayan Ray To: Lukas Bulwahn Cc: linux-kernel@vger.kernel.org diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 23697a6b1eaa..f0032166dfc1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5656,7 +5656,7 @@ sub process { $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && #Ignore some three character SI units explicitly, like MiB and KHz $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) { - while ($var =~ m{($Ident)}g) { + while ($var =~ m{\b($Ident)}g) { my $word = $1; next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/); if ($check) { base-commit: c4681547bcce777daf576925a966ffa824edd09d -- 2.31.1