[libvirt] [PATCH v2 15/22] Remove unnecessary curly brackets in rest of src/[o-u]*/

Martin Kletzander mkletzan at redhat.com
Thu Nov 13 14:37:43 UTC 2014


Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/openvz/openvz_conf.c        |  3 +--
 src/openvz/openvz_driver.c      | 27 +++++++++------------------
 src/phyp/phyp_driver.c          | 21 +++++++--------------
 src/remote/remote_driver.c      |  3 +--
 src/rpc/virnetclient.c          |  9 +++------
 src/rpc/virnetserver.c          |  3 +--
 src/rpc/virnetserverclient.c    |  3 +--
 src/rpc/virnetserverservice.c   |  3 +--
 src/security/security_manager.c |  3 +--
 src/security/virt-aa-helper.c   |  9 +++------
 src/uml/uml_conf.c              |  6 ++----
 src/uml/uml_driver.c            |  9 +++------
 12 files changed, 33 insertions(+), 66 deletions(-)

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 856c9f5..edf37d0 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -660,9 +660,8 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
     if (fp == NULL)
         goto error;
     temp_fd = open(temp_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
-    if (temp_fd == -1) {
+    if (temp_fd == -1)
         goto error;
-    }

     while (1) {
         if (getline(&line, &line_size, fp) <= 0)
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index a0346b4..d9e27a1 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -619,9 +619,8 @@ static int openvzDomainSuspend(virDomainPtr dom)

     if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
         openvzSetProgramSentinal(prog, vm->def->name);
-        if (virRun(prog, NULL) < 0) {
+        if (virRun(prog, NULL) < 0)
             goto cleanup;
-        }
         virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER);
     }

@@ -658,9 +657,8 @@ static int openvzDomainResume(virDomainPtr dom)

   if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
       openvzSetProgramSentinal(prog, vm->def->name);
-      if (virRun(prog, NULL) < 0) {
+      if (virRun(prog, NULL) < 0)
           goto cleanup;
-      }
       virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNPAUSED);
   }

@@ -1113,9 +1111,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,

     openvzSetProgramSentinal(progstart, vm->def->name);

-    if (virRun(progstart, NULL) < 0) {
+    if (virRun(progstart, NULL) < 0)
         goto cleanup;
-    }

     vm->pid = strtoI(vm->def->name);
     vm->def->id = vm->pid;
@@ -1172,9 +1169,8 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
     }

     openvzSetProgramSentinal(prog, vm->def->name);
-    if (virRun(prog, NULL) < 0) {
+    if (virRun(prog, NULL) < 0)
         goto cleanup;
-    }

     vm->pid = strtoI(vm->def->name);
     vm->def->id = vm->pid;
@@ -1218,9 +1214,8 @@ openvzDomainUndefineFlags(virDomainPtr dom,
         goto cleanup;

     openvzSetProgramSentinal(prog, vm->def->name);
-    if (virRun(prog, NULL) < 0) {
+    if (virRun(prog, NULL) < 0)
         goto cleanup;
-    }

     if (virDomainObjIsActive(vm)) {
         vm->persistent = 0;
@@ -1264,9 +1259,8 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
     }

     openvzSetProgramSentinal(prog, vm->def->name);
-    if (virRun(prog, NULL) < 0) {
+    if (virRun(prog, NULL) < 0)
         goto cleanup;
-    }
     ret = 0;

  cleanup:
@@ -1357,9 +1351,8 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
     str_vcpus[31] = '\0';

     openvzSetProgramSentinal(prog, vm->def->name);
-    if (virRun(prog, NULL) < 0) {
+    if (virRun(prog, NULL) < 0)
         return -1;
-    }

     vm->def->maxvcpus = vm->def->vcpus = nvcpus;
     return 0;
@@ -1719,9 +1712,8 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm,
     snprintf(str_mem, sizeof(str_mem), "%llu", mem * 1024);

     openvzSetProgramSentinal(prog, vm->def->name);
-    if (virRun(prog, NULL) < 0) {
+    if (virRun(prog, NULL) < 0)
         goto cleanup;
-    }

     return 0;

@@ -2052,9 +2044,8 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
             return -1;
         }

-        if (openvzSetDiskQuota(vmdef, fs, persist) < 0) {
+        if (openvzSetDiskQuota(vmdef, fs, persist) < 0)
             return -1;
-        }
         cur->space_hard_limit = fs->space_hard_limit;
         cur->space_soft_limit = fs->space_soft_limit;
     } else {
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 386d25f..269d030 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -172,9 +172,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
         }
     }

-    if (channel == NULL) {
+    if (channel == NULL)
         goto err;
-    }

     while ((rc = libssh2_channel_exec(channel, cmd)) ==
            LIBSSH2_ERROR_EAGAIN) {
@@ -185,9 +184,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
         }
     }

-    if (rc != 0) {
+    if (rc != 0)
         goto err;
-    }

     for (;;) {
         /* loop until we block */
@@ -223,9 +221,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status,
         }
     }

-    if (rc == 0) {
+    if (rc == 0)
         exitcode = libssh2_channel_get_exit_status(channel);
-    }

     (*exit_status) = exitcode;
     libssh2_channel_free(channel);
@@ -731,9 +728,8 @@ phypUUIDTable_Pull(virConnectPtr conn)
         do {
             amount = sizeof(buffer);

-            if ((fileinfo.st_size - got) < amount) {
+            if ((fileinfo.st_size - got) < amount)
                 amount = fileinfo.st_size - got;
-            }

             rc = libssh2_channel_read(channel, buffer, amount);
             if (rc > 0) {
@@ -849,9 +845,8 @@ phypUUIDTable_Init(virConnectPtr conn)

  cleanup:
     if (ret < 0 && table_created) {
-        for (i = 0; i < uuid_table->nlpars; i++) {
+        for (i = 0; i < uuid_table->nlpars; i++)
             VIR_FREE(uuid_table->lpars[i]);
-        }
         VIR_FREE(uuid_table->lpars);
     }
     VIR_FREE(ids);
@@ -1718,18 +1713,16 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)

     domain_name = escape_specialcharacters(domain->name);

-    if (domain_name == NULL) {
+    if (domain_name == NULL)
         goto cleanup;
-    }

     if (VIR_STRDUP(def->os.type, "aix") < 0)
         goto cleanup;

     dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL,
                                   VIR_DOMAIN_XML_INACTIVE);
-    if (!dev) {
+    if (!dev)
         goto cleanup;
-    }

     if (!
         (vios_name =
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 5ca6655..04e5360 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4069,9 +4069,8 @@ static sasl_callback_t *remoteAuthMakeCallbacks(int *credtype, int ncredtype)
     sasl_callback_t *cbs;
     size_t i;
     int n;
-    if (VIR_ALLOC_N(cbs, ncredtype+1) < 0) {
+    if (VIR_ALLOC_N(cbs, ncredtype+1) < 0)
         return NULL;
-    }

     for (i = 0, n = 0; i < ncredtype; i++) {
         int id = remoteAuthCredVir2SASL(credtype[i]);
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index a156fe1..8657b0e 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -160,9 +160,8 @@ static void virNetClientCallQueue(virNetClientCallPtr *head,
                                   virNetClientCallPtr call)
 {
     virNetClientCallPtr tmp = *head;
-    while (tmp && tmp->next) {
+    while (tmp && tmp->next)
         tmp = tmp->next;
-    }
     if (tmp)
         tmp->next = call;
     else
@@ -237,9 +236,8 @@ static bool virNetClientCallMatchPredicate(virNetClientCallPtr head,
 {
     virNetClientCallPtr tmp = head;
     while (tmp) {
-        if (pred(tmp, opaque)) {
+        if (pred(tmp, opaque))
             return true;
-        }
         tmp = tmp->next;
     }
     return false;
@@ -1535,9 +1533,8 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
         /* If we have existing SASL decoded data, pretend
          * the socket became readable so we consume it
          */
-        if (virNetSocketHasCachedData(client->sock)) {
+        if (virNetSocketHasCachedData(client->sock))
             fds[0].revents |= POLLIN;
-        }

         /* If wantClose flag is set, pretend there was an error on the socket
          */
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 3d3e422..47d83ba 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -1233,9 +1233,8 @@ void virNetServerClose(virNetServerPtr srv)

     virObjectLock(srv);

-    for (i = 0; i < srv->nservices; i++) {
+    for (i = 0; i < srv->nservices; i++)
         virNetServerServiceClose(srv->services[i]);
-    }

     virObjectUnlock(srv);
 }
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index c6ef84c..b2a4fdf 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -496,9 +496,8 @@ virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr objec
                            _("Missing privateData field in JSON state document"));
             goto error;
         }
-        if (!(client->privateData = privNew(client, child, privOpaque))) {
+        if (!(client->privateData = privNew(client, child, privOpaque)))
             goto error;
-        }
         client->privateDataFreeFunc = privFree;
         client->privateDataPreExecRestart = privPreExecRestart;
     }
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index 647007b..d84b6de 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -516,7 +516,6 @@ void virNetServerServiceClose(virNetServerServicePtr svc)
     if (!svc)
         return;

-    for (i = 0; i < svc->nsocks; i++) {
+    for (i = 0; i < svc->nsocks; i++)
         virNetSocketClose(svc->socks[i]);
-    }
 }
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
index 8671620..302f54d 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -875,9 +875,8 @@ virSecurityManagerGetNested(virSecurityManagerPtr mgr)
 {
     virSecurityManagerPtr* list = NULL;

-    if (STREQ("stack", mgr->drv->name)) {
+    if (STREQ("stack", mgr->drv->name))
         return virSecurityStackGetNested(mgr);
-    }

     if (VIR_ALLOC_N(list, 2) < 0)
         return NULL;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index e102c3c..c4e687c 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1253,13 +1253,11 @@ main(int argc, char **argv)

     /* clear the environment */
     environ = NULL;
-    if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0) {
+    if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0)
         vah_error(ctl, 1, _("could not set PATH"));
-    }

-    if (setenv("IFS", " \n\t", 1) != 0) {
+    if (setenv("IFS", " \n\t", 1) != 0)
         vah_error(ctl, 1, _("could not set IFS"));
-    }

     if (!(progname = strrchr(argv[0], '/')))
         progname = argv[0];
@@ -1290,9 +1288,8 @@ main(int argc, char **argv)
     } else if (ctl->cmd == 'c' || ctl->cmd == 'r') {
         char *included_files = NULL;

-        if (ctl->cmd == 'c' && virFileExists(profile)) {
+        if (ctl->cmd == 'c' && virFileExists(profile))
             vah_error(ctl, 1, _("profile exists"));
-        }

         if (ctl->append && ctl->newfile) {
             if (vah_add_file(&buf, ctl->newfile, "rw") != 0)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index a99e8e9..9dcd4ae 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -172,9 +172,8 @@ umlBuildCommandLineNet(virConnectPtr conn,
     case VIR_DOMAIN_NET_TYPE_ETHERNET:
         /* ethNNN=tuntap,tapname,macaddr,gateway */
         virBufferAddLit(&buf, "tuntap,");
-        if (def->ifname) {
+        if (def->ifname)
             virBufferAdd(&buf, def->ifname, -1);
-        }
         if (def->data.ethernet.ipaddr) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("IP address not supported for ethernet interface"));
@@ -215,9 +214,8 @@ umlBuildCommandLineNet(virConnectPtr conn,
         }
         bridge = virNetworkGetBridgeName(network);
         virNetworkFree(network);
-        if (bridge == NULL) {
+        if (bridge == NULL)
             goto error;
-        }

         if (umlConnectTapDevice(conn, vm, def, bridge) < 0) {
             VIR_FREE(bridge);
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 2baf2fa..b01d631 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -336,9 +336,8 @@ umlInotifyEvent(int watch,

         dom = virDomainObjListFindByName(driver->domains, name);

-        if (!dom) {
+        if (!dom)
             continue;
-        }

         if (e.mask & IN_DELETE) {
             VIR_DEBUG("Got inotify domain shutdown '%s'", name);
@@ -1335,9 +1334,8 @@ static int umlGetProcessInfo(unsigned long long *cpuTime, pid_t pid)
     FILE *pidinfo;
     unsigned long long usertime, systime;

-    if (virAsprintf(&proc, "/proc/%lld/stat", (long long) pid) < 0) {
+    if (virAsprintf(&proc, "/proc/%lld/stat", (long long) pid) < 0)
         return -1;
-    }

     if (!(pidinfo = fopen(proc, "r"))) {
         /* VM probably shut down, so fake 0 */
@@ -2306,9 +2304,8 @@ static int umlDomainDetachUmlDisk(struct uml_driver *driver,
     char *reply;

     for (i = 0; i < vm->def->ndisks; i++) {
-        if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst)) {
+        if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst))
             break;
-        }
     }

     if (i == vm->def->ndisks) {
-- 
2.1.3




More information about the libvir-list mailing list