1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-10 05:17:59 +03:00

syntax-check: Add the rule to forbid whitespace before ";"

Only a few cases are allowed:

1) The expression is empty for "for" loop, E.g.

  for (i = 0; ; i++)

2) An empty statement

  while (write(statuswrite, &status, 1) == -1 &&
         errno == EINTR)
      ; /* empty */

3) ";" is inside double-quote, I.e, as part of const string. E.g.

  vshPrint(ctl, "a ; b ; cd;\n");

The "for" loop in src/rpc/virnettlscontext.c is the special case,
1) applies for it, so change it together in this patch.
This commit is contained in:
Osier Yang 2013-05-21 18:01:01 +08:00
parent 1f49c0e138
commit ba0880b25c
2 changed files with 22 additions and 1 deletions

View File

@ -109,6 +109,27 @@ foreach my $file (@ARGV) {
$ret = 1; $ret = 1;
last; last;
} }
# Forbid whitespace before ";". Things like below are allowed:
#
# 1) The expression is empty for "for" loop. E.g.
# for (i = 0; ; i++)
#
# 2) An empty statement. E.g.
# while (write(statuswrite, &status, 1) == -1 &&
# errno == EINTR)
# ;
#
# 3) ";" is inside double-quote, I.e, as part of const string. E.g.
# printf("%s", "a ; b\n");
while ($data =~ /[^;\s]\s+;/) {
# Inside the double-quote
if ($data !~ /"[^"]*\s;/) {
print "$file:$.: $line";
$ret = 1;
}
last;
}
} }
close FILE; close FILE;
} }