aboutsummaryrefslogtreecommitdiff
path: root/lib/checksrc.pl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-05-11 23:40:58 +0200
committerDaniel Stenberg <daniel@haxx.se>2018-05-21 23:21:47 +0200
commitcb529b713f4882ac65a074ae8d87faa41d19168e (patch)
treeb9f23f33a817107127020630c7b9b5764e8685f0 /lib/checksrc.pl
parentf3d836b73601fc6d14cb917e1cd72f43b9056dff (diff)
checksrc: make sure sizeof() is used *with* parentheses
... and unify the source code to adhere. Closes #2563
Diffstat (limited to 'lib/checksrc.pl')
-rwxr-xr-xlib/checksrc.pl12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index c90e245ee..daff07bf5 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -63,6 +63,7 @@ my %warnings = (
'NOSPACEEQUALS' => 'equals sign without preceding space',
'SEMINOSPACE' => 'semicolon without following space',
'MULTISPACE' => 'multiple spaces used when not suitable',
+ 'SIZEOFNOPAREN' => 'use of sizeof without parentheses',
);
sub readwhitelist {
@@ -417,6 +418,17 @@ sub scanfile {
}
}
+ # check for "sizeof" without parenthesis
+ if(($l =~ /^(.*)sizeof *([ (])/) && ($2 ne "(")) {
+ if($1 =~ / *\#/) {
+ # this is a #if, treat it differently
+ }
+ else {
+ checkwarn("SIZEOFNOPAREN", $line, length($1)+6, $file, $l,
+ "sizeof without parenthesis");
+ }
+ }
+
# check for comma without space
if($l =~ /^(.*),[^ \n]/) {
my $pref=$1;