summaryrefslogtreecommitdiff
path: root/lib/checksrc.pl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-11-23 08:29:42 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-11-24 23:58:22 +0100
commitec0a5c96ac2f31d09651f04c8b24a30d1f6fa118 (patch)
treef69f3209e86f32be62b416b97fccdd458d8803a9 /lib/checksrc.pl
parentdbadaebfc4e9d453232795f54d4fe5618cf8e84d (diff)
downloadcurl-ec0a5c96ac2f31d09651f04c8b24a30d1f6fa118.tar.gz
checksrc: verify ASTERISKNOSPACE
Detects (char*) and 'char*foo' uses.
Diffstat (limited to 'lib/checksrc.pl')
-rwxr-xr-xlib/checksrc.pl13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index 9eb76f47e..9a74a6f46 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -56,7 +56,8 @@ my %warnings = (
'BADCOMMAND' => 'bad !checksrc! instruction',
'UNUSEDIGNORE' => 'a warning ignore was not used',
'OPENCOMMENT' => 'file ended with a /* comment still "open"',
- 'ASTERISKSPACE' => 'pointer declared with space after asterisk'
+ 'ASTERISKSPACE' => 'pointer declared with space after asterisk',
+ 'ASTERISKNOSPACE' => 'pointer declared without space before asterisk'
);
sub readwhitelist {
@@ -473,11 +474,17 @@ sub scanfile {
}
# check for 'char * name'
- if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost) *\*) (\w+)/) && ($3 ne "const")) {
- checkwarn("ASTERISKSPACE",
+ if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost) *(\*+)) (\w+)/) && ($4 ne "const")) {
+ checkwarn("ASTERISKNOSPACE",
$line, length($1), $file, $ol,
"no space after declarative asterisk");
}
+ # check for 'char*'
+ if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost|sockaddr_in|FILE)\*)/)) {
+ checkwarn("ASTERISKNOSPACE",
+ $line, length($1)-1, $file, $ol,
+ "no space before asterisk");
+ }
$line++;
$prevl = $ol;
}