lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <93eb25ab04c2f7436a49f301c2c79a49cb209c44.camel@perches.com>
Date:   Thu, 27 May 2021 15:05:44 -0700
From:   Joe Perches <joe@...ches.com>
To:     Antonio Borneo <borneo.antonio@...il.com>,
        Andy Whitcroft <apw@...onical.com>,
        Dwaipayan Ray <dwaipayanray1@...il.com>,
        Lukas Bulwahn <lukas.bulwahn@...il.com>
Cc:     linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] checkpatch: fix incorrect camelcase detection on
 numeric constant

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: <xFF>
> 	#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 <borneo.antonio@...il.com>
> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> To: Andy Whitcroft <apw@...onical.com>
> To: Joe Perches <joe@...ches.com>
> To: Dwaipayan Ray <dwaipayanray1@...il.com>
> To: Lukas Bulwahn <lukas.bulwahn@...il.com>
> Cc: linux-kernel@...r.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ