]> xenbits.xensource.com Git - libvirt.git/commitdiff
syntax-check: Add the rule to forbid whitespace before ";"
authorOsier Yang <jyang@redhat.com>
Tue, 21 May 2013 10:01:01 +0000 (18:01 +0800)
committerOsier Yang <jyang@redhat.com>
Wed, 22 May 2013 05:16:03 +0000 (13:16 +0800)
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.

build-aux/bracket-spacing.pl
src/rpc/virnettlscontext.c

index d3a916f4b09e720b25dfbddfcacd1981fd1e2f4e..fbe66669eacd06cfc1531def9ace643f9742e366 100755 (executable)
@@ -109,6 +109,27 @@ foreach my $file (@ARGV) {
             $ret = 1;
             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;
 }
index 1a7ccb8732f23461f81a87225e0ba06a5b6ffc7e..305eee95b469a6cf7304030d7cd96b242394a380 100644 (file)
@@ -292,7 +292,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
     bool allowClient = false, allowServer = false;
 
     critical = 0;
-    for (i = 0 ; ; i++) {
+    for (i = 0; ; i++) {
         size = 0;
         status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, NULL);