1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

checksrc: verify ASTERISKNOSPACE

Detects (char*) and 'char*foo' uses.
This commit is contained in:
Daniel Stenberg 2016-11-23 08:29:42 +01:00
parent dbadaebfc4
commit ec0a5c96ac

View File

@ -56,7 +56,8 @@ my %warnings = (
'BADCOMMAND' => 'bad !checksrc! instruction', 'BADCOMMAND' => 'bad !checksrc! instruction',
'UNUSEDIGNORE' => 'a warning ignore was not used', 'UNUSEDIGNORE' => 'a warning ignore was not used',
'OPENCOMMENT' => 'file ended with a /* comment still "open"', '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 { sub readwhitelist {
@ -473,11 +474,17 @@ sub scanfile {
} }
# check for 'char * name' # check for 'char * name'
if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost) *\*) (\w+)/) && ($3 ne "const")) { if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost) *(\*+)) (\w+)/) && ($4 ne "const")) {
checkwarn("ASTERISKSPACE", checkwarn("ASTERISKNOSPACE",
$line, length($1), $file, $ol, $line, length($1), $file, $ol,
"no space after declarative asterisk"); "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++; $line++;
$prevl = $ol; $prevl = $ol;
} }