[PATCH] maint: improve syntax check for space around =

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Laine Stump noted on IRC that syntax check wasn't flagging his
typo of 'i= 0'.  This fixes it.

* build-aux/bracket-spacing.pl: Tighten space-around-= rule.
* src/storage/storage_backend.c
(virStorageBackendCreateExecCommand): Fix offenders.
* src/util/virnuma.c (virNumaGetDistances): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSnapshotDeleteMetadataOnly)
(vboxNetworkGetXMLDesc): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainLookupByName):
Likewise.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 build-aux/bracket-spacing.pl  |   11 +++++------
 src/storage/storage_backend.c |    2 +-
 src/util/virnuma.c            |    2 +-
 src/vbox/vbox_tmpl.c          |    6 +++---
 src/xenapi/xenapi_driver.c    |    2 +-
 5 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl
index e4ae8f0..ac01a56 100755
--- a/build-aux/bracket-spacing.pl
+++ b/build-aux/bracket-spacing.pl
@@ -32,8 +32,8 @@ foreach my $file (@ARGV) {
     while (defined (my $line = <FILE>)) {
         my $data = $line;

-        # Kill any quoted , ; or "
-        $data =~ s/'[";,]'/'X'/g;
+        # Kill any quoted , ; = or "
+        $data =~ s/'[";,=]'/'X'/g;

         # Kill any quoted strings
         $data =~ s,"([^\\\"]|\\.)*","XXX",g;
@@ -147,10 +147,9 @@ foreach my $file (@ARGV) {

         # Require spaces around assignment '=', compounds and '=='
         # with the exception of virAssertCmpInt()
-        while ($data =~ /[^!<>&|\-+*\/%\^'= ]=\+[^=]/ ||
-               $data =~ /[^!<>&|\-+*\/%\^'=]=[^= \\\n]/ ||
-               $data =~ /[\S]==/ ||
-               ($data =~ /==[^\s,]/ && $data !~ /[\s]virAssertCmpInt\(/)) {
+        $data =~ s/(virAssertCmpInt\(.* ).?=,/$1op,/;
+        while ($data =~ /[^ ]\b[!<>&|\-+*\/%\^=]?=[^=]/ ||
+               $data =~ /=[^= \\\n]/) {
             print "$file:$.: $line";
             $ret = 1;
             last;
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 5cada39..42eee75 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -615,7 +615,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,

         if (virCommandRun(cmd, NULL) == 0) {
             /* command was successfully run, check if the file was created */
-            if (stat(vol->target.path, &st) >=0)
+            if (stat(vol->target.path, &st) >= 0)
                 filecreated = true;
         }
     }
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 7a11a3b..9e6e5f7 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -451,7 +451,7 @@ virNumaGetDistances(int node,

     *ndistances = max_node + 1;

-    for (i = 0; i<= max_node; i++) {
+    for (i = 0; i <= max_node; i++) {
         if (!virNumaNodeIsAvailable(node))
             continue;

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index ccba736..bccb4a7 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -8397,7 +8397,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)

     virDomainPtr dom = snapshot->domain;
     VBOX_OBJECT_CHECK(dom->conn, int, -1);
-    virDomainSnapshotDefPtr def= NULL;
+    virDomainSnapshotDefPtr def = NULL;
     char *defXml = NULL;
     vboxIID domiid = VBOX_IID_INITIALIZER;
     nsresult rc;
@@ -10173,7 +10173,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network,
                                                                  &dhcpServer);
                 if (dhcpServer) {
                     ipdef->nranges = 1;
-                    if (VIR_ALLOC_N(ipdef->ranges, ipdef->nranges) >=0) {
+                    if (VIR_ALLOC_N(ipdef->ranges, ipdef->nranges) >= 0) {
                         PRUnichar *ipAddressUtf16     = NULL;
                         PRUnichar *networkMaskUtf16   = NULL;
                         PRUnichar *fromIPAddressUtf16 = NULL;
@@ -10211,7 +10211,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network,
                     }

                     ipdef->nhosts = 1;
-                    if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) >=0) {
+                    if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) >= 0) {
                         if (VIR_STRDUP(ipdef->hosts[0].name, network->name) < 0) {
                             VIR_FREE(ipdef->hosts);
                             ipdef->nhosts = 0;
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 5bcfd29..50331c9 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -691,7 +691,7 @@ xenapiDomainLookupByName(virConnectPtr conn,
         }
         vm = vms->contents[0];
         xen_vm_get_uuid(session, &uuid, vm);
-        if (uuid!=NULL) {
+        if (uuid != NULL) {
             ignore_value(virUUIDParse(uuid, raw_uuid));
             domP = virGetDomain(conn, name, raw_uuid);
             if (domP != NULL) {
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]