Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

checkpatch: improve TYPECAST_INT_CONSTANT test message

Improve the TYPECAST_INT_CONSTANT test by showing the suggested conversion
for various type of uses like (unsigned int)1 to 1U.

Link: https://lkml.kernel.org/r/ecefe8dcb93fe7028311b69dd297ba52224233d4.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Joe Perches and committed by
Linus Torvalds
0972b8bf adb2da82

+10 -10
+10 -10
scripts/checkpatch.pl
··· 6518 6518 if ($line =~ /(\(\s*$C90_int_types\s*\)\s*)($Constant)\b/) { 6519 6519 my $cast = $1; 6520 6520 my $const = $2; 6521 + my $suffix = ""; 6522 + my $newconst = $const; 6523 + $newconst =~ s/${Int_type}$//; 6524 + $suffix .= 'U' if ($cast =~ /\bunsigned\b/); 6525 + if ($cast =~ /\blong\s+long\b/) { 6526 + $suffix .= 'LL'; 6527 + } elsif ($cast =~ /\blong\b/) { 6528 + $suffix .= 'L'; 6529 + } 6521 6530 if (WARN("TYPECAST_INT_CONSTANT", 6522 - "Unnecessary typecast of c90 int constant\n" . $herecurr) && 6531 + "Unnecessary typecast of c90 int constant - '$cast$const' could be '$const$suffix'\n" . $herecurr) && 6523 6532 $fix) { 6524 - my $suffix = ""; 6525 - my $newconst = $const; 6526 - $newconst =~ s/${Int_type}$//; 6527 - $suffix .= 'U' if ($cast =~ /\bunsigned\b/); 6528 - if ($cast =~ /\blong\s+long\b/) { 6529 - $suffix .= 'LL'; 6530 - } elsif ($cast =~ /\blong\b/) { 6531 - $suffix .= 'L'; 6532 - } 6533 6533 $fixed[$fixlinenr] =~ s/\Q$cast\E$const\b/$newconst$suffix/; 6534 6534 } 6535 6535 }