Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp17141pxj; Thu, 27 May 2021 19:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEtc6vzcAUs61jYT5NiNa0v2vewKvsWIRd91+PQHkjEa8S3DLLn0kRXaV9GCi+DySz06DI X-Received: by 2002:a17:906:3ed0:: with SMTP id d16mr6796608ejj.16.1622170335461; Thu, 27 May 2021 19:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622170335; cv=none; d=google.com; s=arc-20160816; b=L44zrvZutbQ6ydKPOEukY8HrVbSQXlJdWf8Ircmm/aHbV467O4rKakKTFjAIm9YHpO hQti2SeaJAkeXBmUtL06uj+ZYHVYqLymZ0xw1j+hi6YQ1w4ttBBThwZdb4embcn2J2As 9nDTNqHN+ew+vEg4cUIW73pJNfBkLtXuO+pWqUJ5tMjCrPF+Sf/8crCCOu28Y8URJOhm VuiKcKTcDRSNeA9TfXdGQyQlWyY9Zf9bLrRC6B8Mhdwzi29M04R76UKKz3tnNu6bOM+g amXBkm7/vNWABBigLxbXQHL3Hr2fEiI8zkUhcBR71VzmVPu6wptA9HwTP9mXOjG5Edd2 VHiQ== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=ktrg/Oz7xSt84CCa2Foduv0MFtilJRok/d1sGFqy8zw=; b=yxJ1lkD+pxRMLHKt3Jb/vUehU6zf3seERxuWkrCqhpTD+ifW2wBcF+LipMOjO/E1qX pG2v5Yw4m5Z8HnLdLACkzQZwrjZGrD7nvgOWh7mTSubBKTtcoxCcW2zLjAI2hovvmrbh v1oKg/7oA5+41m2nl5GvTX5UqaMTHoRYhioiSyLgdK40YarTJ09wB3HAZZfJZ9NFvnOz 19n6xeNXKas5ZHpJFwt9NlCRQpdYDmQ7qbXgDjgli0WsB340RnYG14YJS46lSvyYN8ME TcIom0owy0fM0Yd6eWmKR1jOURE+Ju78KO8GTOIVfR1KmF/BgAvO2IMaYzclvERan/th FKdQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si4184171edu.41.2021.05.27.19.51.11; Thu, 27 May 2021 19:52:15 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbhE0WHW (ORCPT + 99 others); Thu, 27 May 2021 18:07:22 -0400 Received: from smtprelay0008.hostedemail.com ([216.40.44.8]:42806 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234514AbhE0WHV (ORCPT ); Thu, 27 May 2021 18:07:21 -0400 Received: from omf05.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id D9EC618007A3B; Thu, 27 May 2021 22:05:47 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA id B9C62B2798; Thu, 27 May 2021 22:05:46 +0000 (UTC) Message-ID: <93eb25ab04c2f7436a49f301c2c79a49cb209c44.camel@perches.com> Subject: Re: [PATCH] checkpatch: fix incorrect camelcase detection on numeric constant From: Joe Perches To: Antonio Borneo , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn Cc: linux-kernel@vger.kernel.org, Andrew Morton Date: Thu, 27 May 2021 15:05:44 -0700 In-Reply-To: <20210527214741.180449-1-borneo.antonio@gmail.com> References: <20210527214741.180449-1-borneo.antonio@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B9C62B2798 X-Spam-Status: No, score=-0.03 X-Stat-Signature: 5es8hhmm9e4w48x77ea7crwmzh3ywsds X-Rspamd-Server: rspamout03 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18GTx/EgcI2qEfKMz8iuhkQVdAKIGZMNF0= X-HE-Tag: 1622153146-319043 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-05-27 at 23:47 +0200, Antonio Borneo wrote: > 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. The thing there is that 0xFF is not an $Ident as it doesn't start with _[A-Za-z] so it's not excluding constants per-se. So, you've added the right code, but just not quite the best commit message. > Force the match to start at word boundary so the constants will be > filtered-out. Anyway, thanks and cheers, Joe > > 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