[PATCH 15/15] Remove unneeded curly brackets around oneline code blocks

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

 



As stated in our contributor guidelines, we don't want curly brackets
around oneline code block (with some exceptions).

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 daemon/libvirtd.c                    | 15 +++++----------
 daemon/remote.c                      | 15 +++++----------
 examples/object-events/event-test.c  |  3 +--
 examples/openauth/openauth.c         |  9 +++------
 tools/virsh-console.c                | 15 +++++----------
 tools/virsh-domain.c                 | 30 ++++++++++--------------------
 tools/virsh-edit.c                   |  6 ++----
 tools/virsh-host.c                   |  3 +--
 tools/virsh-interface.c              |  6 ++----
 tools/virsh-pool.c                   |  6 ++----
 tools/virsh-volume.c                 | 15 +++++----------
 tools/virsh.c                        | 18 ++++++------------
 tools/wireshark/src/packet-libvirt.c |  6 ++----
 13 files changed, 49 insertions(+), 98 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 1864bfd..b7f82c5 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -981,9 +981,8 @@ static int migrateProfile(void)
     if (!(home = virGetUserDirectory()))
         goto cleanup;

-    if (virAsprintf(&old_base, "%s/.libvirt", home) < 0) {
+    if (virAsprintf(&old_base, "%s/.libvirt", home) < 0)
         goto cleanup;
-    }

     /* if the new directory is there or the old one is not: do nothing */
     if (!(config_dir = virGetUserConfigDirectory()))
@@ -998,21 +997,18 @@ static int migrateProfile(void)
     }

     /* test if we already attempted to migrate first */
-    if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0) {
+    if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0)
         goto cleanup;
-    }
-    if (virFileExists(updated)) {
+    if (virFileExists(updated))
         goto cleanup;
-    }

     config_home = virGetEnvBlockSUID("XDG_CONFIG_HOME");
     if (config_home && config_home[0] != '\0') {
         if (VIR_STRDUP(xdg_dir, config_home) < 0)
             goto cleanup;
     } else {
-        if (virAsprintf(&xdg_dir, "%s/.config", home) < 0) {
+        if (virAsprintf(&xdg_dir, "%s/.config", home) < 0)
             goto cleanup;
-        }
     }

     old_umask = umask(077);
@@ -1164,9 +1160,8 @@ int main(int argc, char **argv) {

         c = getopt_long(argc, argv, "ldf:p:t:vVh", opts, &optidx);

-        if (c == -1) {
+        if (c == -1)
             break;
-        }

         switch (c) {
         case 0:
diff --git a/daemon/remote.c b/daemon/remote.c
index c93c97a..54819a1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -500,9 +500,8 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
               authScheme, callback->callbackID);

     VIR_DEBUG("Subject %d", subject->nidentity);
-    for (i = 0; i < subject->nidentity; i++) {
+    for (i = 0; i < subject->nidentity; i++)
         VIR_DEBUG("  %s=%s", subject->identities[i].type, subject->identities[i].name);
-    }

     /* build return data */
     memset(&data, 0, sizeof(data));
@@ -3255,9 +3254,8 @@ remoteDispatchAuthPolkit(virNetServerPtr server,
     }

     if (virNetServerClientGetUNIXIdentity(client, &callerUid, &callerGid,
-                                          &callerPid, &timestamp) < 0) {
+                                          &callerPid, &timestamp) < 0)
         goto authfail;
-    }

     if (timestamp == 0) {
         VIR_WARN("Failing polkit auth due to missing client (pid=%lld) start time",
@@ -4268,9 +4266,8 @@ remoteDispatchDomainOpenGraphicsFd(virNetServerPtr server ATTRIBUTE_UNUSED,

  cleanup:
     VIR_FORCE_CLOSE(fd);
-    if (rv < 0) {
+    if (rv < 0)
         virNetMessageSaveError(rerr);
-    }

     if (dom)
         virDomainFree(dom);
@@ -5689,9 +5686,8 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPtr server ATTRIBUTE_UNUSED,
     rv = 0;

  cleanup:
-    for (i = 0; i < nfiles; i++) {
+    for (i = 0; i < nfiles; i++)
         VIR_FORCE_CLOSE(files[i]);
-    }
     VIR_FREE(files);
     if (rv < 0)
         virNetMessageSaveError(rerr);
@@ -5741,9 +5737,8 @@ static int remoteDispatchDomainCreateWithFiles(virNetServerPtr server ATTRIBUTE_
     rv = 0;

  cleanup:
-    for (i = 0; i < nfiles; i++) {
+    for (i = 0; i < nfiles; i++)
         VIR_FORCE_CLOSE(files[i]);
-    }
     VIR_FREE(files);
     if (rv < 0)
         virNetMessageSaveError(rerr);
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index 0c6faf4..8987ee5 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -730,9 +730,8 @@ int main(int argc, char **argv)
     virConnectUnregisterCloseCallback(dconn, connectClose);

     VIR_DEBUG("Closing connection");
-    if (dconn && virConnectClose(dconn) < 0) {
+    if (dconn && virConnectClose(dconn) < 0)
         printf("error closing\n");
-    }

     printf("done\n");
     return 0;
diff --git a/examples/openauth/openauth.c b/examples/openauth/openauth.c
index fae96e0..0be977e 100644
--- a/examples/openauth/openauth.c
+++ b/examples/openauth/openauth.c
@@ -132,9 +132,8 @@ showDomains(virConnectPtr conn)
         goto out;
     }

-    if (numNames > 0) {
+    if (numNames > 0)
         printf("Inactive domains:\n");
-    }

     for (i = 0; i < numNames; i++) {
         printf("  %s\n", *(nameList + i));
@@ -181,9 +180,8 @@ authCallback(virConnectCredentialPtr cred, unsigned int ncred, void *cbdata)
         case VIR_CRED_AUTHNAME:
             cred[i].result = strdup(authData->username);

-            if (cred[i].result == NULL) {
+            if (cred[i].result == NULL)
                 return -1;
-            }

             cred[i].resultlen = strlen(cred[i].result);
             break;
@@ -191,9 +189,8 @@ authCallback(virConnectCredentialPtr cred, unsigned int ncred, void *cbdata)
         case VIR_CRED_PASSPHRASE:
             cred[i].result = strdup(authData->password);

-            if (cred[i].result == NULL) {
+            if (cred[i].result == NULL)
                 return -1;
-            }

             cred[i].resultlen = strlen(cred[i].result);
             break;
diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index c245df7..656c646 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -190,9 +190,8 @@ virConsoleEventOnStream(virStreamPtr st,
                                      VIR_STREAM_EVENT_READABLE);

     if (events & VIR_STREAM_EVENT_ERROR ||
-        events & VIR_STREAM_EVENT_HANGUP) {
+        events & VIR_STREAM_EVENT_HANGUP)
         virConsoleShutdown(con);
-    }
 }


@@ -224,9 +223,8 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
                    con->terminalToStream.offset,
                    avail);
         if (got < 0) {
-            if (errno != EAGAIN) {
+            if (errno != EAGAIN)
                 virConsoleShutdown(con);
-            }
             return;
         }
         if (got == 0) {
@@ -246,9 +244,8 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
     }

     if (events & VIR_EVENT_HANDLE_ERROR ||
-        events & VIR_EVENT_HANDLE_HANGUP) {
+        events & VIR_EVENT_HANDLE_HANGUP)
         virConsoleShutdown(con);
-    }
 }


@@ -268,9 +265,8 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
                      con->streamToTerminal.data,
                      con->streamToTerminal.offset);
         if (done < 0) {
-            if (errno != EAGAIN) {
+            if (errno != EAGAIN)
                 virConsoleShutdown(con);
-            }
             return;
         }
         memmove(con->streamToTerminal.data,
@@ -290,9 +286,8 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
         virEventUpdateHandle(con->stdoutWatch, 0);

     if (events & VIR_EVENT_HANDLE_ERROR ||
-        events & VIR_EVENT_HANDLE_HANGUP) {
+        events & VIR_EVENT_HANDLE_HANGUP)
         virConsoleShutdown(con);
-    }
 }


diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index bd5f404..60a33f8 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -161,9 +161,8 @@ vshNodeGetCPUCount(virConnectPtr conn)
     if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) {
         /* fall back to nodeinfo */
         vshResetLibvirtError();
-        if (virNodeGetInfo(conn, &nodeinfo) == 0) {
+        if (virNodeGetInfo(conn, &nodeinfo) == 0)
             ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
-        }
     }
     return ret;
 }
@@ -3327,9 +3326,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA;
         snapshots_safe = true;
     }
-    if (nvram) {
+    if (nvram)
         flags |= VIR_DOMAIN_UNDEFINE_NVRAM;
-    }

     if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
         return false;
@@ -3379,9 +3377,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
         flags &= ~VIR_DOMAIN_UNDEFINE_MANAGED_SAVE;
         managed_save_safe = true;
     }
-    if (has_snapshots == 0) {
+    if (has_snapshots == 0)
         snapshots_safe = true;
-    }
     if (has_snapshots_metadata == 0) {
         flags &= ~VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA;
         snapshots_safe = true;
@@ -6061,9 +6058,8 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
     int cpu, lastcpu;
     bool bit, lastbit, isInvert;

-    if (!cpumaps || cpumaplen <= 0 || maxcpu <= 0 || vcpuindex < 0) {
+    if (!cpumaps || cpumaplen <= 0 || maxcpu <= 0 || vcpuindex < 0)
         return false;
-    }

     bit = lastbit = isInvert = false;
     lastcpu = -1;
@@ -6083,9 +6079,8 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
             vshPrint(ctl, "-%d", cpu - 1);
         lastbit = bit;
     }
-    if (bit && !isInvert) {
+    if (bit && !isInvert)
         vshPrint(ctl, "-%d", maxcpu - 1);
-    }

     return true;
 }
@@ -6242,9 +6237,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }

-    if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) {
+    if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
         goto cleanup;
-    }

     cpumaplen = VIR_CPU_MAPLEN(maxcpu);

@@ -7809,13 +7803,11 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
     kibibytes = VIR_DIV_UP(bytes, 1024);

     if (flags == -1) {
-        if (virDomainSetMemory(dom, kibibytes) != 0) {
+        if (virDomainSetMemory(dom, kibibytes) != 0)
             ret = false;
-        }
     } else {
-        if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) {
+        if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0)
             ret = false;
-        }
     }

     virDomainFree(dom);
@@ -9369,9 +9361,8 @@ doMigrate(void *opaque)
     if (vshCommandOptBool(cmd, "rdma-pin-all"))
         flags |= VIR_MIGRATE_RDMA_PIN_ALL;

-    if (vshCommandOptBool(cmd, "offline")) {
+    if (vshCommandOptBool(cmd, "offline"))
         flags |= VIR_MIGRATE_OFFLINE;
-    }

     if (vshCommandOptBool(cmd, "abort-on-error"))
         flags |= VIR_MIGRATE_ABORT_ON_ERROR;
@@ -10034,9 +10025,8 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)

     obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt);
     if (obj == NULL || obj->type != XPATH_STRING ||
-        obj->stringval == NULL || obj->stringval[0] == 0) {
+        obj->stringval == NULL || obj->stringval[0] == 0)
         goto cleanup;
-    }
     vshPrint(ctl, "%s\n", (const char *)obj->stringval);
     ret = true;

diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 10298f6..41a6d53 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -85,9 +85,8 @@ do {
         goto edit_cleanup;

     /* Compare original XML with edited.  Has it changed at all? */
-    if (STREQ(doc, doc_edited)) {
+    if (STREQ(doc, doc_edited))
         EDIT_NOT_CHANGED;
-    }

  redefine:
     msg = NULL;
@@ -109,9 +108,8 @@ do {
     }

     /* Everything checks out, so redefine the object. */
-    if (!msg && !(EDIT_DEFINE)) {
+    if (!msg && !(EDIT_DEFINE))
         msg = _("Failed.");
-    }

     if (msg) {
         int c = vshAskReedit(ctl, msg);
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 4a3ff28..8afffc8 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -376,9 +376,8 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
                 goto cleanup;

             vshPrint(ctl, _("Node %d:\n"), cell);
-            for (j = 0; j < npages; j++) {
+            for (j = 0; j < npages; j++)
                 vshPrint(ctl, "%uKiB: %lld\n", pagesize[j], counts[j]);
-            }
             vshPrint(ctl, "%c", '\n');
         }

diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 6cacaf1..c429fc7 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -824,9 +824,8 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)

     /* Get a handle to the original device */
     if (!(if_handle = vshCommandOptInterfaceBy(ctl, cmd, "interface",
-                                               &if_name, VSH_BYNAME))) {
+                                               &if_name, VSH_BYNAME)))
         goto cleanup;
-    }

     /* Name for new bridge device */
     if (vshCommandOptStringReq(ctl, cmd, "bridge", &br_name) < 0)
@@ -1046,9 +1045,8 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)

     /* Get a handle to the original device */
     if (!(br_handle = vshCommandOptInterfaceBy(ctl, cmd, "bridge",
-                                               &br_name, VSH_BYNAME))) {
+                                               &br_name, VSH_BYNAME)))
         goto cleanup;
-    }

     nostart = vshCommandOptBool(cmd, "no-start");

diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 0b8dba5..a05608b 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -470,13 +470,11 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
     if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;

-    if (vshCommandOptBool(cmd, "no-overwrite")) {
+    if (vshCommandOptBool(cmd, "no-overwrite"))
         flags |= VIR_STORAGE_POOL_BUILD_NO_OVERWRITE;
-    }

-    if (vshCommandOptBool(cmd, "overwrite")) {
+    if (vshCommandOptBool(cmd, "overwrite"))
         flags |= VIR_STORAGE_POOL_BUILD_OVERWRITE;
-    }

     if (virStoragePoolBuild(pool, flags) == 0) {
         vshPrint(ctl, _("Pool %s built\n"), name);
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 4f810f8..1859aa4 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -687,9 +687,8 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
         return false;
     }

-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
+    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
-    }

     if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
         goto cleanup;
@@ -885,9 +884,8 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;

-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
+    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
-    }

     if (virStorageVolDelete(vol, 0) == 0) {
         vshPrint(ctl, _("Vol %s deleted\n"), name);
@@ -945,9 +943,8 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
     int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;
     int funcRet;

-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
+    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
-    }

     if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0)
         goto out;
@@ -1642,9 +1639,8 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)

     /* Use the supplied string to locate the volume */
     if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
-                                   VSH_BYUUID))) {
+                                   VSH_BYUUID)))
         return false;
-    }

     /* Look up the parent storage pool for the volume */
     pool = virStoragePoolLookupByVolume(vol);
@@ -1741,9 +1737,8 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
     virStorageVolPtr vol;
     char * StorageVolPath;

-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) {
+    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
-    }

     if ((StorageVolPath = virStorageVolGetPath(vol)) == NULL) {
         virStorageVolFree(vol);
diff --git a/tools/virsh.c b/tools/virsh.c
index 036b517..eb648bd 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -499,9 +499,8 @@ vshPrintRaw(vshControl *ctl, ...)
     char *key;

     va_start(ap, ctl);
-    while ((key = va_arg(ap, char *)) != NULL) {
+    while ((key = va_arg(ap, char *)) != NULL)
         vshPrint(ctl, "%s\r\n", key);
-    }
     va_end(ap);
 }

@@ -874,9 +873,8 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
         return false;
     }

-    if (vshCommandOptString(cmd, "dir", &dir) <= 0) {
+    if (vshCommandOptString(cmd, "dir", &dir) <= 0)
         dir = dir_malloced = virGetUserDirectory();
-    }
     if (!dir)
         dir = "/";

@@ -1136,9 +1134,8 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
     const vshCmdOptDef *ret = NULL;
     char *alias = NULL;

-    if (STREQ(name, helpopt.name)) {
+    if (STREQ(name, helpopt.name))
         return &helpopt;
-    }

     for (i = 0; cmd->opts && cmd->opts[i].name; i++) {
         const vshCmdOptDef *opt = &cmd->opts[i];
@@ -1642,9 +1639,8 @@ vshCommandOptString(const vshCmd *cmd, const char *name, const char **value)
     if (ret <= 0)
         return ret;

-    if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) {
+    if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
         return -1;
-    }
     *value = arg->data;
     return 1;
 }
@@ -1839,9 +1835,8 @@ vshCommandOptArgv(const vshCmd *cmd, const vshCmdOpt *opt)
     opt = opt ? opt->next : cmd->opts;

     while (opt) {
-        if (opt->def->type == VSH_OT_ARGV) {
+        if (opt->def->type == VSH_OT_ARGV)
             return opt;
-        }
         opt = opt->next;
     }
     return NULL;
@@ -3703,9 +3698,8 @@ main(int argc, char **argv)
     else
         progname++;

-    if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"))) {
+    if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
         ctl->name = vshStrdup(ctl, defaultConn);
-    }

     vshInitDebug(ctl);

diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/packet-libvirt.c
index 5c3c369..f7aa7ed 100644
--- a/tools/wireshark/src/packet-libvirt.c
+++ b/tools/wireshark/src/packet-libvirt.c
@@ -249,9 +249,8 @@ find_payload_dissector(guint32 proc, guint32 type,

     first = pds[0].proc;
     last = pds[length-1].proc;
-    if (proc < first || proc > last) {
+    if (proc < first || proc > last)
         return NULL;
-    }

     pd = &pds[proc-first];
     /* There is no guarantee to proc numbers has no gap */
@@ -329,9 +328,8 @@ dissect_libvirt_payload_xdr_data(tvbuff_t *tvb, proto_tree *tree, gint payload_l
     xdr_destroy(&xdrs);
     g_free(payload_data);

-    if (nfds != 0) {
+    if (nfds != 0)
         dissect_libvirt_fds(tvb, start + payload_length, nfds);
-    }
 }

 static void
-- 
2.1.3

--
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]