diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index db7521fa37..d796bc5da0 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -554,7 +554,7 @@ sub scanfile { # check for !checksrc! commands if($l =~ /\!checksrc\! (.*)/) { my $cmd = $1; - checksrc($cmd, $line, $file, $l) + checksrc($cmd, $line, $file, $l); } if($l =~ /^#line (\d+) \"([^\"]*)\"/) { @@ -670,7 +670,7 @@ sub scanfile { $line, length($1), $file, $l, "\/\/ comment"); } - if($l =~ /^\s*#\s*if\s+!?\s*defined\([a-zA-Z0-9_]+\)$/) { + if($l =~ /^(\s*#\s*if\s+!?\s*defined\()[a-zA-Z0-9_]+\)$/) { checkwarn("IFDEFSINGLE", $line, length($1), $file, $l, "use ifdef/ifndef for single macro checks"); } diff --git a/tests/data/test1185 b/tests/data/test1185 index 0bbc85900d..217a0a1604 100644 --- a/tests/data/test1185 +++ b/tests/data/test1185 @@ -215,12 +215,12 @@ void startfunc(int a, int b) { ./%LOGDIR/code1185.c:62:25: warning: use of alsobad is banned (BANNEDFUNC) *buffer_len = (ssize_t)alsobad((char *)buffer, NULL, 16); ^ -./%LOGDIR/code1185.c:64:1: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE) +./%LOGDIR/code1185.c:64:14: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE) # if defined(SINGLE_MACRO) - ^ -./%LOGDIR/code1185.c:65:1: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE) + ^ +./%LOGDIR/code1185.c:65:17: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE) #if ! defined(__macro_10) - ^ + ^ ./%LOGDIR/code1185.c:65:1: warning: space before preprocessor hash (CPPSPACE) #if ! defined(__macro_10) ^