Fix cstyle.pl warnings

As of perl v5.22.1 the following warnings are generated:

* Redundant argument in printf at scripts/cstyle.pl line 194

* Unescaped left brace in regex is deprecated, passed through
  in regex; marked by <-- HERE in m/\S{ <-- HERE / at
  scripts/cstyle.pl line 608.

They have been addressed by escaping the left braces and by
providing the correct number of arguments to printf based on
the fmt specifier set by the verbose option.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4723
This commit is contained in:
Brian Behlendorf 2016-06-03 09:08:14 -07:00
parent 1eeb4562a7
commit f866a4ea1f
1 changed files with 16 additions and 4 deletions

View File

@ -191,7 +191,11 @@ my $no_errs = 0; # set for CSTYLED-protected lines
sub err($) { sub err($) {
my ($error) = @_; my ($error) = @_;
unless ($no_errs) { unless ($no_errs) {
if ($verbose) {
printf $fmt, $filename, $., $error, $line; printf $fmt, $filename, $., $error, $line;
} else {
printf $fmt, $filename, $., $error;
}
$err_stat = 1; $err_stat = 1;
} }
} }
@ -200,7 +204,11 @@ sub err_prefix($$) {
my ($prevline, $error) = @_; my ($prevline, $error) = @_;
my $out = $prevline."\n".$line; my $out = $prevline."\n".$line;
unless ($no_errs) { unless ($no_errs) {
if ($verbose) {
printf $fmt, $filename, $., $error, $out; printf $fmt, $filename, $., $error, $out;
} else {
printf $fmt, $filename, $., $error;
}
$err_stat = 1; $err_stat = 1;
} }
} }
@ -208,7 +216,11 @@ sub err_prefix($$) {
sub err_prev($) { sub err_prev($) {
my ($error) = @_; my ($error) = @_;
unless ($no_errs) { unless ($no_errs) {
if ($verbose) {
printf $fmt, $filename, $. - 1, $error, $prev; printf $fmt, $filename, $. - 1, $error, $prev;
} else {
printf $fmt, $filename, $. - 1, $error;
}
$err_stat = 1; $err_stat = 1;
} }
} }
@ -605,7 +617,7 @@ line: while (<$filehandle>) {
if (/^\s*\(void\)[^ ]/) { if (/^\s*\(void\)[^ ]/) {
err("missing space after (void) cast"); err("missing space after (void) cast");
} }
if (/\S{/ && !/{{/) { if (/\S\{/ && !/\{\{/) {
err("missing space before left brace"); err("missing space before left brace");
} }
if ($in_function && /^\s+{/ && if ($in_function && /^\s+{/ &&