[libvirt] [PATCH 07/15] Remove unneeded curly brackets around oneline code blocks in src/util/

Martin Kletzander mkletzan at redhat.com
Thu Nov 6 16:38:32 UTC 2014


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 at redhat.com>
---
 src/util/virauth.c               | 21 +++++++--------------
 src/util/virbitmap.c             |  6 ++----
 src/util/virbuffer.c             |  3 +--
 src/util/vircgroup.c             |  3 +--
 src/util/vircommand.c            | 12 ++++--------
 src/util/virconf.c               | 15 +++++----------
 src/util/virdbus.c               |  6 ++----
 src/util/virdnsmasq.c            |  6 ++----
 src/util/vireventpoll.c          | 12 ++++--------
 src/util/virfile.c               |  9 +++------
 src/util/virfirewall.c           |  6 ++----
 src/util/virhostdev.c            |  6 ++----
 src/util/viriscsi.c              | 12 ++++--------
 src/util/virjson.c               |  3 +--
 src/util/virlockspace.c          |  6 ++----
 src/util/virlog.c                |  6 ++----
 src/util/virnetdev.c             | 12 ++++--------
 src/util/virnetdevbridge.c       |  3 +--
 src/util/virnetdevmacvlan.c      | 15 +++++----------
 src/util/virnetdevtap.c          |  9 +++------
 src/util/virnetdevvlan.c         |  3 +--
 src/util/virnetdevvportprofile.c |  6 ++----
 src/util/virpci.c                | 33 +++++++++++----------------------
 src/util/virsexpr.c              | 30 ++++++++++--------------------
 src/util/virstorageencryption.c  |  3 +--
 src/util/virstoragefile.c        |  6 ++----
 src/util/virsysinfo.c            |  3 +--
 src/util/virthreadpool.c         |  9 +++------
 src/util/virutil.c               | 12 ++++--------
 src/util/virxml.c                | 18 ++++++------------
 30 files changed, 98 insertions(+), 196 deletions(-)

diff --git a/src/util/virauth.c b/src/util/virauth.c
index f82e546..737a430 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -168,19 +168,16 @@ virAuthGetUsernamePath(const char *path,

     if (defaultUsername != NULL) {
         if (virAsprintf(&prompt, _("Enter username for %s [%s]"), hostname,
-                        defaultUsername) < 0) {
+                        defaultUsername) < 0)
             return NULL;
-        }
     } else {
-        if (virAsprintf(&prompt, _("Enter username for %s"), hostname) < 0) {
+        if (virAsprintf(&prompt, _("Enter username for %s"), hostname) < 0)
             return NULL;
-        }
     }

     for (ncred = 0; ncred < auth->ncredtype; ncred++) {
-        if (auth->credtype[ncred] != VIR_CRED_AUTHNAME) {
+        if (auth->credtype[ncred] != VIR_CRED_AUTHNAME)
             continue;
-        }

         cred.type = VIR_CRED_AUTHNAME;
         cred.prompt = prompt;
@@ -189,9 +186,8 @@ virAuthGetUsernamePath(const char *path,
         cred.result = NULL;
         cred.resultlen = 0;

-        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
             VIR_FREE(cred.result);
-        }

         break;
     }
@@ -244,15 +240,13 @@ virAuthGetPasswordPath(const char *path,
     memset(&cred, 0, sizeof(virConnectCredential));

     if (virAsprintf(&prompt, _("Enter %s's password for %s"), username,
-                    hostname) < 0) {
+                    hostname) < 0)
         return NULL;
-    }

     for (ncred = 0; ncred < auth->ncredtype; ncred++) {
         if (auth->credtype[ncred] != VIR_CRED_PASSPHRASE &&
-            auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) {
+            auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT)
             continue;
-        }

         cred.type = auth->credtype[ncred];
         cred.prompt = prompt;
@@ -261,9 +255,8 @@ virAuthGetPasswordPath(const char *path,
         cred.result = NULL;
         cred.resultlen = 0;

-        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
             VIR_FREE(cred.result);
-        }

         break;
     }
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 04a2388..05c50e4 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -640,9 +640,8 @@ virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)

     bits = bitmap->map[nl] & ~((1UL << nb) - 1);

-    while (bits == 0 && ++nl < bitmap->map_len) {
+    while (bits == 0 && ++nl < bitmap->map_len)
         bits = bitmap->map[nl];
-    }

     if (bits == 0)
         return -1;
@@ -726,9 +725,8 @@ virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t pos)

     bits = ~bitmap->map[nl] & ~((1UL << nb) - 1);

-    while (bits == 0 && ++nl < bitmap->map_len) {
+    while (bits == 0 && ++nl < bitmap->map_len)
         bits = ~bitmap->map[nl];
-    }

     if (nl == bitmap->map_len - 1) {
         /* Ensure tail bits are ignored.  */
diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c
index 52ffa08..16a81e7 100644
--- a/src/util/virbuffer.c
+++ b/src/util/virbuffer.c
@@ -368,9 +368,8 @@ virBufferVasprintf(virBufferPtr buf, const char *format, va_list argptr)
         buf->content[buf->use] = 0;

         grow_size = (count + 1 > 1000) ? count + 1 : 1000;
-        if (virBufferGrow(buf, grow_size) < 0) {
+        if (virBufferGrow(buf, grow_size) < 0)
             return;
-        }

         size = buf->size - buf->use;
         if ((count = vsnprintf(&buf->content[buf->use],
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 9bbe694..df41ec0 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1246,9 +1246,8 @@ virCgroupSetPartitionSuffix(const char *path, char **res)
         if (i == 1 &&
             (STREQ(tokens[i], "machine") ||
              STREQ(tokens[i], "system") ||
-             STREQ(tokens[i], "user"))) {
+             STREQ(tokens[i], "user")))
             continue;
-        }
         /* If there is no suffix set already, then
          * add ".partition"
          */
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index cbe94f8..80b86cf 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -558,9 +558,8 @@ virExec(virCommandPtr cmd)

     pid = virFork();

-    if (pid < 0) {
+    if (pid < 0)
         goto cleanup;
-    }

     if (pid) { /* parent */
         VIR_FORCE_CLOSE(null);
@@ -731,9 +730,8 @@ virExec(virCommandPtr cmd)
                   (int)cmd->uid, (int)cmd->gid, cmd->capabilities);
         if (virSetUIDGIDWithCaps(cmd->uid, cmd->gid, groups, ngroups,
                                  cmd->capabilities,
-                                 !!(cmd->flags & VIR_EXEC_CLEAR_CAPS)) < 0) {
+                                 !!(cmd->flags & VIR_EXEC_CLEAR_CAPS)) < 0)
             goto fork_error;
-        }
     }

     if (cmd->pwd) {
@@ -3021,9 +3019,8 @@ virCommandRunNul(virCommandPtr cmd,
         v[i] = NULL;

     virCommandSetOutputFD(cmd, &fd);
-    if (virCommandRunAsync(cmd, NULL) < 0) {
+    if (virCommandRunAsync(cmd, NULL) < 0)
         goto cleanup;
-    }

     if ((fp = VIR_FDOPEN(fd, "r")) == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3050,9 +3047,8 @@ virCommandRunNul(virCommandPtr cmd,
             if (func(n_tok, v, data) < 0)
                 goto cleanup;
             n_tok = 0;
-            for (i = 0; i < n_columns; i++) {
+            for (i = 0; i < n_columns; i++)
                 VIR_FREE(v[i]);
-            }
         }
     }

diff --git a/src/util/virconf.c b/src/util/virconf.c
index e221fb5..0a17eff 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -502,9 +502,8 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
             }
             NEXT;
             SKIP_BLANKS_AND_EOL;
-            if (CUR == ']') {
+            if (CUR == ']')
                 break;
-            }
             tmp = virConfParseValue(ctxt);
             if (tmp == NULL) {
                 virConfFreeList(lst);
@@ -529,9 +528,8 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
                          _("numbers not allowed in VMX format"));
             return NULL;
         }
-        if (virConfParseLong(ctxt, &l) < 0) {
+        if (virConfParseLong(ctxt, &l) < 0)
             return NULL;
-        }
         type = VIR_CONF_LONG;
     } else {
         virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting a value"));
@@ -654,9 +652,8 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
     char *comm = NULL;

     SKIP_BLANKS_AND_EOL;
-    if (CUR == '#') {
+    if (CUR == '#')
         return virConfParseComment(ctxt);
-    }
     name = virConfParseName(ctxt);
     if (name == NULL)
         return -1;
@@ -768,9 +765,8 @@ virConfReadFile(const char *filename, unsigned int flags)
         return NULL;
     }

-    if ((len = virFileReadAll(filename, MAX_CONFIG_FILE_SIZE, &content)) < 0) {
+    if ((len = virFileReadAll(filename, MAX_CONFIG_FILE_SIZE, &content)) < 0)
         return NULL;
-    }

     conf = virConfParse(filename, content, len, flags);

@@ -888,9 +884,8 @@ virConfSetValue(virConfPtr conf,

     cur = conf->entries;
     while (cur != NULL) {
-        if ((cur->name != NULL) && (STREQ(cur->name, setting))) {
+        if ((cur->name != NULL) && (STREQ(cur->name, setting)))
             break;
-        }
         prev = cur;
         cur = cur->next;
     }
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 7c24cbf..0e2739b 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -73,9 +73,8 @@ static DBusConnection *virDBusBusInit(DBusBusType type, DBusError *dbuserr)
                                              virDBusAddWatch,
                                              virDBusRemoveWatch,
                                              virDBusToggleWatch,
-                                             bus, NULL)) {
+                                             bus, NULL))
         return NULL;
-    }
     return bus;
 }

@@ -546,9 +545,8 @@ static void virDBusTypeStackFree(virDBusTypeStack **stack,
     /* The iter in the first level of the stack is the
      * root iter which must not be freed
      */
-    for (i = 1; i < *nstack; i++) {
+    for (i = 1; i < *nstack; i++)
         VIR_FREE((*stack)[i].iter);
-    }
     VIR_FREE(*stack);
 }

diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index d2c4aa9..6314258 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -633,9 +633,8 @@ static int dnsmasqCapsOnceInit(void)
     if (!(dnsmasqCapsClass = virClassNew(virClassForObject(),
                                          "dnsmasqCaps",
                                          sizeof(dnsmasqCaps),
-                                         dnsmasqCapsDispose))) {
+                                         dnsmasqCapsDispose)))
         return -1;
-    }

     return 0;
 }
@@ -726,9 +725,8 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
                              caps->binaryPath);
         return -1;
     }
-    if (!force && caps->mtime == sb.st_mtime) {
+    if (!force && caps->mtime == sb.st_mtime)
         return 0;
-    }
     caps->mtime = sb.st_mtime;

     /* Make sure the binary we are about to try exec'ing exists.
diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c
index 13f40dc..6113741 100644
--- a/src/util/vireventpoll.c
+++ b/src/util/vireventpoll.c
@@ -221,9 +221,8 @@ int virEventPollAddTimeout(int frequency,
     unsigned long long now;
     int ret;

-    if (virTimeMillisNow(&now) < 0) {
+    if (virTimeMillisNow(&now) < 0)
         return -1;
-    }

     virMutexLock(&eventLoop.lock);
     if (eventLoop.timeoutsCount == eventLoop.timeoutsAlloc) {
@@ -270,9 +269,8 @@ void virEventPollUpdateTimeout(int timer, int frequency)
         return;
     }

-    if (virTimeMillisNow(&now) < 0) {
+    if (virTimeMillisNow(&now) < 0)
         return;
-    }

     virMutexLock(&eventLoop.lock);
     for (i = 0; i < eventLoop.timeoutsCount; i++) {
@@ -485,9 +483,8 @@ static int virEventPollDispatchHandles(int nfds, struct pollfd *fds)
     for (i = 0, n = 0; n < nfds && i < eventLoop.handlesCount; n++) {
         while (i < eventLoop.handlesCount &&
                (eventLoop.handles[i].fd != fds[n].fd ||
-                eventLoop.handles[i].events == 0)) {
+                eventLoop.handles[i].events == 0))
             i++;
-        }
         if (i == eventLoop.handlesCount)
             break;

@@ -643,9 +640,8 @@ int virEventPollRunOnce(void)
     ret = poll(fds, nfds, timeout);
     if (ret < 0) {
         EVENT_DEBUG("Poll got error event %d", errno);
-        if (errno == EINTR || errno == EAGAIN) {
+        if (errno == EINTR || errno == EAGAIN)
             goto retry;
-        }
         virReportSystemError(errno, "%s",
                              _("Unable to poll on file handles"));
         goto error_unlocked;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 64f0e5b..475aeab 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1180,9 +1180,8 @@ virBuildPathInternal(char **path, ...)
     va_end(ap);

     *path = virBufferContentAndReset(&buf);
-    if (*path == NULL) {
+    if (*path == NULL)
         ret = -1;
-    }

     return ret;
 }
@@ -2047,9 +2046,8 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
         /* XXX This makes assumptions about errno being < 255, which is
          * not true on Hurd.  */
         VIR_FORCE_CLOSE(pair[1]);
-        if (ret < 0) {
+        if (ret < 0)
             VIR_FORCE_CLOSE(fd);
-        }
         ret = -ret;
         if ((ret & 0xff) != ret) {
             VIR_WARN("unable to pass desired return value %d", ret);
@@ -2273,9 +2271,8 @@ virDirCreate(const char *path,
     if ((!(flags & VIR_DIR_CREATE_AS_UID))
         || (geteuid() != 0)
         || ((uid == 0) && (gid == 0))
-        || ((flags & VIR_DIR_CREATE_ALLOW_EXIST) && (stat(path, &st) >= 0))) {
+        || ((flags & VIR_DIR_CREATE_ALLOW_EXIST) && (stat(path, &st) >= 0)))
         return virDirCreateNoFork(path, mode, uid, gid, flags);
-    }

     ngroups = virGetGroupList(uid, gid, &groups);
     if (ngroups < 0)
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index bab1634..49afb78 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -321,9 +321,8 @@ virFirewallAddRuleFullV(virFirewallPtr firewall,
     rule->queryOpaque = opaque;
     rule->ignoreErrors = ignoreErrors;

-    while ((str = va_arg(args, char *)) != NULL) {
+    while ((str = va_arg(args, char *)) != NULL)
         ADD_ARG(rule, str);
-    }

     if (group->addingRollback) {
         if (VIR_APPEND_ELEMENT_COPY(group->rollback,
@@ -529,9 +528,8 @@ void virFirewallRuleAddArgList(virFirewallPtr firewall,

     va_start(list, rule);

-    while ((str = va_arg(list, char *)) != NULL) {
+    while ((str = va_arg(list, char *)) != NULL)
         ADD_ARG(rule, str);
-    }

     va_end(list);

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 18ff96b..bea44e6 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -578,9 +578,8 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
          if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
              hostdev->parent.data.net) {
              if (virHostdevNetConfigReplace(hostdev, uuid,
-                                            hostdev_mgr->stateDir) < 0) {
+                                            hostdev_mgr->stateDir) < 0)
                  goto resetvfnetconfig;
-             }
          }
          last_processed_hostdev_vf = i;
     }
@@ -1491,9 +1490,8 @@ virHostdevPCINodeDeviceDetach(virHostdevManagerPtr hostdev_mgr,
     virObjectLock(hostdev_mgr->inactivePCIHostdevs);

     if (virPCIDeviceDetach(pci, hostdev_mgr->activePCIHostdevs,
-                           hostdev_mgr->inactivePCIHostdevs) < 0) {
+                           hostdev_mgr->inactivePCIHostdevs) < 0)
         goto out;
-    }

     ret = 0;
  out:
diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
index 5e29be9..e492ca7 100644
--- a/src/util/viriscsi.c
+++ b/src/util/viriscsi.c
@@ -157,9 +157,8 @@ virStorageBackendIQNFound(const char *initiatoriqn,
         *newline = '\0';

         iqn = strrchr(line, ',');
-        if (iqn == NULL) {
+        if (iqn == NULL)
             continue;
-        }
         iqn++;

         if (STREQ(iqn, initiatoriqn)) {
@@ -185,9 +184,8 @@ virStorageBackendIQNFound(const char *initiatoriqn,
         ret = IQN_ERROR;

  out:
-    if (ret == IQN_MISSING) {
+    if (ret == IQN_MISSING)
         VIR_DEBUG("Could not find interface with IQN '%s'", iqn);
-    }

     VIR_FREE(line);
     VIR_FORCE_FCLOSE(fp);
@@ -298,9 +296,8 @@ virISCSIConnection(const char *portal,
             break;
         case IQN_MISSING:
             if (virStorageBackendCreateIfaceIQN(initiatoriqn,
-                                                &ifacename) != 0) {
+                                                &ifacename) != 0)
                 goto cleanup;
-            }
             break;
         case IQN_ERROR:
         default:
@@ -451,9 +448,8 @@ virISCSIScanTargets(const char *portal,
         *ntargetsret = list.ntargets;
         *targetsret = list.targets;
     } else {
-        for (i = 0; i < list.ntargets; i++) {
+        for (i = 0; i < list.ntargets; i++)
             VIR_FREE(list.targets[i]);
-        }
         VIR_FREE(list.targets);
     }

diff --git a/src/util/virjson.c b/src/util/virjson.c
index 3ffa19f..b18a642 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -1246,9 +1246,8 @@ virJSONParserHandleStartMap(void *ctx)
     }

     if (VIR_REALLOC_N(parser->state,
-                      parser->nstate + 1) < 0) {
+                      parser->nstate + 1) < 0)
         return 0;
-    }

     parser->state[parser->nstate].value = value;
     parser->state[parser->nstate].key = NULL;
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index 8969ab0..2366a74 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -679,9 +679,8 @@ int virLockSpaceReleaseResource(virLockSpacePtr lockspace,
     }

     for (i = 0; i < res->nOwners; i++) {
-        if (res->owners[i] == owner) {
+        if (res->owners[i] == owner)
             break;
-        }
     }

     if (i == res->nOwners) {
@@ -723,9 +722,8 @@ virLockSpaceRemoveResourcesForOwner(const void *payload,
     VIR_DEBUG("res %s owner %lld", res->name, (unsigned long long)data->owner);

     for (i = 0; i < res->nOwners; i++) {
-        if (res->owners[i] == data->owner) {
+        if (res->owners[i] == data->owner)
             break;
-        }
     }

     if (i == res->nOwners)
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 286ad9e..a7da505 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -578,9 +578,8 @@ virLogVMessage(virLogSourcePtr source,
     /*
      * serialize the error message, add level and timestamp
      */
-    if (virVasprintfQuiet(&str, fmt, vargs) < 0) {
+    if (virVasprintfQuiet(&str, fmt, vargs) < 0)
         goto cleanup;
-    }

     ret = virLogFormatString(&msg, linenr, funcname, priority, str);
     if (ret < 0)
@@ -1025,9 +1024,8 @@ static int virLogAddOutputToJournald(int priority)
         return -1;
     }
     if (virLogDefineOutput(virLogOutputToJournald, virLogCloseJournald, NULL,
-                           priority, VIR_LOG_TO_JOURNALD, NULL, 0) < 0) {
+                           priority, VIR_LOG_TO_JOURNALD, NULL, 0) < 0)
         return -1;
-    }
     return 0;
 }
 # endif /* USE_JOURNALD */
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 3831009..bea3f13 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -851,9 +851,8 @@ int virNetDevSetIPv4Address(const char *ifname,
     /* format up a broadcast address if this is IPv4 */
     if ((VIR_SOCKET_ADDR_IS_FAMILY(addr, AF_INET)) &&
         ((virSocketAddrBroadcastByPrefix(addr, prefix, &broadcast) < 0) ||
-         !(bcaststr = virSocketAddrFormat(&broadcast)))) {
+         !(bcaststr = virSocketAddrFormat(&broadcast))))
         goto cleanup;
-    }
 #ifdef IFCONFIG_PATH
     cmd = virCommandNew(IFCONFIG_PATH);
     virCommandAddArg(cmd, ifname);
@@ -1185,9 +1184,8 @@ virNetDevGetVirtualFunctions(const char *pfname,
             goto cleanup;
         }

-        if (virPCIGetNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0) {
+        if (virPCIGetNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0)
             VIR_INFO("VF does not have an interface name");
-        }
     }

     ret = 0;
@@ -1449,9 +1447,8 @@ virNetDevLinkDump(const char *ifname, int ifindex,
         uint32_t ifla_ext_mask = RTEXT_FILTER_VF;

         if (nla_put(nl_msg, IFLA_EXT_MASK,
-                    sizeof(ifla_ext_mask), &ifla_ext_mask) < 0) {
+                    sizeof(ifla_ext_mask), &ifla_ext_mask) < 0)
             goto buffer_too_small;
-        }
     }
 # endif

@@ -1758,9 +1755,8 @@ virNetDevRestoreVfConfig(const char *pflinkdev, int vf,
                     stateDir, pflinkdev, vf) < 0)
         return rc;

-    if (virFileReadAll(path, 128, &fileData) < 0) {
+    if (virFileReadAll(path, 128, &fileData) < 0)
         goto cleanup;
-    }

     if ((vlan = strchr(fileData, '\n'))) {
         char *endptr;
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index d388358..15434de 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -265,9 +265,8 @@ int virNetDevBridgeCreate(const char *brname)
         goto cleanup;
     }

-    if (virNetDevSetName(ifr.ifr_name, brname) == -1) {
+    if (virNetDevSetName(ifr.ifr_name, brname) == -1)
         goto cleanup;
-    }

     ret = 0;
  cleanup:
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index c83341c..0b8118b 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -153,9 +153,8 @@ virNetDevMacVLanCreate(const char *ifname,
     nla_nest_end(nl_msg, linkinfo);

     if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0,
-                          NETLINK_ROUTE, 0) < 0) {
+                          NETLINK_ROUTE, 0) < 0)
         goto cleanup;
-    }

     if (recvbuflen < NLMSG_LENGTH(0) || resp == NULL)
         goto malformed_resp;
@@ -239,9 +238,8 @@ int virNetDevMacVLanDelete(const char *ifname)
         goto buffer_too_small;

     if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0,
-                          NETLINK_ROUTE, 0) < 0) {
+                          NETLINK_ROUTE, 0) < 0)
         goto cleanup;
-    }

     if (recvbuflen < NLMSG_LENGTH(0) || resp == NULL)
         goto malformed_resp;
@@ -682,9 +680,8 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr *hdr,
         }
     }

-    if (!indicate) {
+    if (!indicate)
         return;
-    }

     VIR_INFO("Re-send 802.1qbg associate request:");
     VIR_INFO("  if: %s", calld->cr_ifname);
@@ -851,9 +848,8 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
             return -1;

         if (ret) {
-            if (STRPREFIX(tgifname, prefix)) {
+            if (STRPREFIX(tgifname, prefix))
                 goto create_name;
-            }
             virReportSystemError(EEXIST,
                                  _("Unable to create macvlan device %s"), tgifname);
             return -1;
@@ -983,9 +979,8 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
     int ret = 0;
     int vf = -1;

-    if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
+    if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU)
         ignore_value(virNetDevRestoreMacAddress(linkdev, stateDir));
-    }

     if (ifname) {
         if (virNetDevVPortProfileDisassociate(ifname,
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 3674f9b..57dd044 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -108,9 +108,8 @@ virNetDevTapGetRealDeviceName(char *ifname ATTRIBUTE_UNUSED)
     while (virDirRead(dirp, &dp, "/dev") > 0) {
         if (STRPREFIX(dp->d_name, "tap")) {
             struct ifreq ifr;
-            if (virAsprintf(&devpath, "/dev/%s", dp->d_name) < 0) {
+            if (virAsprintf(&devpath, "/dev/%s", dp->d_name) < 0)
                 goto cleanup;
-            }
             if ((fd = open(devpath, O_RDWR)) < 0) {
                 if (errno == EBUSY) {
                     VIR_FREE(devpath);
@@ -444,9 +443,8 @@ int virNetDevTapCreate(char **ifname,
         VIR_FREE(dev_path);
     }

-    if (virNetDevSetName(ifr.ifr_name, *ifname) == -1) {
+    if (virNetDevSetName(ifr.ifr_name, *ifname) == -1)
         goto cleanup;
-    }


     ret = 0;
@@ -583,9 +581,8 @@ int virNetDevTapCreateInBridgePort(const char *brname,

     if (virtPortProfile) {
         if (virNetDevOpenvswitchAddPort(brname, *ifname, macaddr, vmuuid,
-                                        virtPortProfile, virtVlan) < 0) {
+                                        virtPortProfile, virtVlan) < 0)
             goto error;
-        }
     } else {
         if (virNetDevBridgeAddPort(brname, *ifname) < 0)
             goto error;
diff --git a/src/util/virnetdevvlan.c b/src/util/virnetdevvlan.c
index 4c8bce5..f1b3e72 100644
--- a/src/util/virnetdevvlan.c
+++ b/src/util/virnetdevvlan.c
@@ -58,9 +58,8 @@ virNetDevVlanEqual(const virNetDevVlan *a, const virNetDevVlan *b)
     if (a->trunk != b->trunk ||
         a->nTags != b->nTags ||
         a->nativeMode != b->nativeMode ||
-        a->nativeTag != b->nativeTag) {
+        a->nativeTag != b->nativeTag)
         return false;
-    }

     for (ai = 0; ai < a->nTags; ai++) {
         for (bi = 0; bi < b->nTags; bi++) {
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 6ee20d3..237fe79 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -413,9 +413,8 @@ int virNetDevVPortProfileMerge3(virNetDevVPortProfilePtr *result,

     if ((!fromInterface || (fromInterface->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE)) &&
         (!fromNetwork   || (fromNetwork->virtPortType   == VIR_NETDEV_VPORT_PROFILE_NONE)) &&
-        (!fromPortgroup || (fromPortgroup->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE))) {
+        (!fromPortgroup || (fromPortgroup->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE)))
         return 0;
-    }

     /* at least one of the source profiles is non-empty */
     if (VIR_ALLOC(*result) < 0)
@@ -976,9 +975,8 @@ virNetDevVPortProfileOp8021Qbg(const char *ifname,
     vf = PORT_SELF_VF;

     if (virNetDevVPortProfileGetPhysdevAndVlan(ifname, &physdev_ifindex,
-                                               physdev_ifname, &vlanid) < 0) {
+                                               physdev_ifname, &vlanid) < 0)
         goto cleanup;
-    }

     if (vlanid < 0)
         vlanid = 0;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index d8e465f..f6531b0 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1127,9 +1127,8 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
         goto reprobe;

     /* Xen's pciback.ko wants you to use remove_slot on the specific device */
-    if (virPCIDriverFile(&path, driver, "remove_slot") < 0) {
+    if (virPCIDriverFile(&path, driver, "remove_slot") < 0)
         goto cleanup;
-    }

     if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
         virReportSystemError(errno,
@@ -1214,9 +1213,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
      * is triggered for such a device, it will also be immediately
      * bound by the stub.
      */
-    if (virPCIDriverFile(&path, stubDriverName, "new_id") < 0) {
+    if (virPCIDriverFile(&path, stubDriverName, "new_id") < 0)
         goto cleanup;
-    }

     if (virFileWriteStr(path, dev->id, 0) < 0) {
         virReportSystemError(errno,
@@ -1242,9 +1240,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
      */
     if (!virFileLinkPointsTo(driverLink, stubDriverPath)) {
         /* Xen's pciback.ko wants you to use new_slot first */
-        if (virPCIDriverFile(&path, stubDriverName, "new_slot") < 0) {
+        if (virPCIDriverFile(&path, stubDriverName, "new_slot") < 0)
             goto remove_id;
-        }

         if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
             virReportSystemError(errno,
@@ -1255,9 +1252,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
         }
         dev->remove_slot = true;

-        if (virPCIDriverFile(&path, stubDriverName, "bind") < 0) {
+        if (virPCIDriverFile(&path, stubDriverName, "bind") < 0)
             goto remove_id;
-        }

         if (virFileWriteStr(path, dev->name, 0) < 0) {
             virReportSystemError(errno,
@@ -1363,9 +1359,8 @@ virPCIDeviceDetach(virPCIDevicePtr dev,
      * it's not already there.
      */
     if (inactiveDevs && !virPCIDeviceListFind(inactiveDevs, dev) &&
-        virPCIDeviceListAddCopy(inactiveDevs, dev) < 0) {
+        virPCIDeviceListAddCopy(inactiveDevs, dev) < 0)
         return -1;
-    }

     return 0;
 }
@@ -1505,9 +1500,8 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name)
     char *path = NULL;
     char *id_str;

-    if (virPCIFile(&path, dev->name, id_name) < 0) {
+    if (virPCIFile(&path, dev->name, id_name) < 0)
         return NULL;
-    }

     /* ID string is '0xNNNN\n' ... i.e. 7 bytes */
     if (virFileReadAll(path, 7, &id_str) < 0) {
@@ -1636,9 +1630,8 @@ virPCIDeviceCopy(virPCIDevicePtr dev)
     if (VIR_STRDUP(copy->path, dev->path) < 0 ||
         VIR_STRDUP(copy->stubDriver, dev->stubDriver) < 0 ||
         VIR_STRDUP(copy->used_by_drvname, dev->used_by_drvname) < 0 ||
-        VIR_STRDUP(copy->used_by_domname, dev->used_by_domname) < 0) {
+        VIR_STRDUP(copy->used_by_domname, dev->used_by_domname) < 0)
         goto error;
-    }
     return copy;

  error:
@@ -2365,24 +2358,20 @@ virPCIDeviceAddressParse(char *address,
     int ret = -1;

     if ((address == NULL) || (logStrToLong_ui(address, &p, 16,
-                                              &bdf->domain) == -1)) {
+                                              &bdf->domain) == -1))
         goto out;
-    }

     if ((p == NULL) || (logStrToLong_ui(p+1, &p, 16,
-                                        &bdf->bus) == -1)) {
+                                        &bdf->bus) == -1))
         goto out;
-    }

     if ((p == NULL) || (logStrToLong_ui(p+1, &p, 16,
-                                        &bdf->slot) == -1)) {
+                                        &bdf->slot) == -1))
         goto out;
-    }

     if ((p == NULL) || (logStrToLong_ui(p+1, &p, 16,
-                                        &bdf->function) == -1)) {
+                                        &bdf->function) == -1))
         goto out;
-    }

     ret = 0;

diff --git a/src/util/virsexpr.c b/src/util/virsexpr.c
index f8a0ccd..f5f1d5d 100644
--- a/src/util/virsexpr.c
+++ b/src/util/virsexpr.c
@@ -65,9 +65,8 @@ sexpr_free(struct sexpr *sexpr)
 {
     int serrno = errno;

-    if (sexpr == NULL) {
+    if (sexpr == NULL)
         return;
-    }

     switch (sexpr->kind) {
         case SEXPR_CONS:
@@ -163,9 +162,8 @@ append(struct sexpr *lst, const struct sexpr *value)
     if (nil == NULL)
         return -1;

-    while (lst->kind != SEXPR_NIL) {
+    while (lst->kind != SEXPR_NIL)
         lst = lst->u.s.cdr;
-    }

     lst->kind = SEXPR_CONS;
     lst->u.s.car = (struct sexpr *) value;
@@ -300,9 +298,8 @@ _string2sexpr(const char *buffer, size_t * end)
             ptr = trim(ptr + tmp_len);
         }

-        if (*ptr == ')') {
+        if (*ptr == ')')
             ptr++;
-        }
     } else {
         const char *start;

@@ -325,9 +322,8 @@ _string2sexpr(const char *buffer, size_t * end)
             start = ptr;

             while (*ptr && !c_isspace(*ptr)
-                   && *ptr != ')' && *ptr != '(') {
+                   && *ptr != ')' && *ptr != '(')
                 ptr++;
-            }

             if (VIR_STRNDUP(ret->u.value, start, ptr - start) < 0)
                 goto error;
@@ -394,13 +390,11 @@ sexpr_lookup_key(const struct sexpr *sexpr, const char *node)
     ptr = buffer;
     token = strsep(&ptr, "/");

-    if (sexpr->kind != SEXPR_CONS || sexpr->u.s.car->kind != SEXPR_VALUE) {
+    if (sexpr->kind != SEXPR_CONS || sexpr->u.s.car->kind != SEXPR_VALUE)
         goto cleanup;
-    }

-    if (STRNEQ(sexpr->u.s.car->u.value, token)) {
+    if (STRNEQ(sexpr->u.s.car->u.value, token))
         goto cleanup;
-    }

     for (token = strsep(&ptr, "/"); token; token = strsep(&ptr, "/")) {
         const struct sexpr *i;
@@ -409,9 +403,8 @@ sexpr_lookup_key(const struct sexpr *sexpr, const char *node)
         for (i = sexpr; i->kind != SEXPR_NIL; i = i->u.s.cdr) {
             if (i->kind != SEXPR_CONS ||
                 i->u.s.car->kind != SEXPR_CONS ||
-                i->u.s.car->u.s.car->kind != SEXPR_VALUE) {
+                i->u.s.car->u.s.car->kind != SEXPR_VALUE)
                 continue;
-            }

             if (STREQ(i->u.s.car->u.s.car->u.value, token)) {
                 sexpr = i->u.s.car;
@@ -419,14 +412,12 @@ sexpr_lookup_key(const struct sexpr *sexpr, const char *node)
             }
         }

-        if (i->kind == SEXPR_NIL) {
+        if (i->kind == SEXPR_NIL)
             break;
-        }
     }

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

     result = (struct sexpr *) sexpr;

@@ -538,9 +529,8 @@ sexpr_fmt_node(const struct sexpr *sexpr, const char *fmt, ...)
     result = virVasprintf(&node, fmt, ap);
     va_end(ap);

-    if (result < 0) {
+    if (result < 0)
         return NULL;
-    }

     value = sexpr_node(sexpr, node);

diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c
index b5fed58..ec4a8cb 100644
--- a/src/util/virstorageencryption.c
+++ b/src/util/virstorageencryption.c
@@ -193,9 +193,8 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt)
     ret->format = format;

     n = virXPathNodeSet("./secret", ctxt, &nodes);
-    if (n < 0) {
+    if (n < 0)
         goto cleanup;
-    }
     if (n != 0 && VIR_ALLOC_N(ret->secrets, n) < 0)
         goto cleanup;
     ret->nsecrets = n;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 8e9d115..aa97f75 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1204,9 +1204,8 @@ int virStorageFileGetLVMKey(const char *path,
         char *tmp = *key;

         /* Find first non-space character */
-        while (*tmp && c_isspace(*tmp)) {
+        while (*tmp && c_isspace(*tmp))
             tmp++;
-        }
         /* Kill leading spaces */
         if (tmp != *key)
             memmove(*key, tmp, strlen(tmp)+1);
@@ -1919,9 +1918,8 @@ virStorageSourceInitChainElement(virStorageSourcePtr newelem,
 {
     int ret = -1;

-    if (force) {
+    if (force)
         virStorageSourceSeclabelsClear(newelem);
-    }

     if (!newelem->seclabels &&
         virStorageSourceSeclabelsCopy(newelem, old) < 0)
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 1bb6392..d644dbc 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -179,9 +179,8 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
         eol = strchr(base, '\n');
         cur = strchr(base, ':') + 1;

-        if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
+        if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
             return -1;
-        }
         processor = &ret->processor[ret->nprocessor - 1];

         virSkipSpaces(&cur);
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 4c46f28..0d43696 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -122,9 +122,8 @@ static void virThreadPoolWorker(void *opaque)
         if (job == pool->jobList.firstPrio) {
             virThreadPoolJobPtr tmp = job->next;
             while (tmp) {
-                if (tmp->priority) {
+                if (tmp->priority)
                     break;
-                }
                 tmp = tmp->next;
             }
             pool->jobList.firstPrio = tmp;
@@ -200,9 +199,8 @@ virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
         if (virThreadCreate(&pool->workers[i],
                             true,
                             virThreadPoolWorker,
-                            data) < 0) {
+                            data) < 0)
             goto error;
-        }
         pool->nWorkers++;
     }

@@ -222,9 +220,8 @@ virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
             if (virThreadCreate(&pool->prioWorkers[i],
                                 true,
                                 virThreadPoolWorker,
-                                data) < 0) {
+                                data) < 0)
                 goto error;
-            }
             pool->nPrioWorkers++;
         }
     }
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 1116fda..f35d218 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -603,9 +603,8 @@ char *virIndexToDiskName(int idx, const char *prefix)
     strcpy(name, prefix);
     name[offset + i] = '\0';

-    for (i = i - 1, ctr = idx; ctr >= 0; --i, ctr = ctr / 26 - 1) {
+    for (i = i - 1, ctr = idx; ctr >= 0; --i, ctr = ctr / 26 - 1)
         name[offset + i] = 'a' + (ctr % 26);
-    }

     return name;
 }
@@ -1401,9 +1400,8 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
 # ifdef PR_CAPBSET_DROP
     /* If newer kernel, we need also need setpcap to change the bounding set */
     if ((capBits || need_setgid || need_setuid) &&
-        !capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP)) {
+        !capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP))
         need_setpcap = true;
-    }
     if (need_setpcap)
         capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED, CAP_SETPCAP);
 # endif
@@ -1539,9 +1537,8 @@ virValidateWWN(const char *wwn)
     size_t i;
     const char *p = wwn;

-    if (STRPREFIX(wwn, "0x")) {
+    if (STRPREFIX(wwn, "0x"))
         p += 2;
-    }

     for (i = 0; p[i]; i++) {
         if (!c_isxdigit(p[i]))
@@ -2563,9 +2560,8 @@ virGetListenFDs(void)

         VIR_DEBUG("Disabling inheritance of passed FD %d", fd);

-        if (virSetInherit(fd, false) < 0) {
+        if (virSetInherit(fd, false) < 0)
             VIR_WARN("Couldn't disable inheritance of passed FD %d", fd);
-        }
     }

     return nfds;
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 27ecf14..7f591fb 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -185,9 +185,8 @@ virXPathLongBase(const char *xpath,
     } else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
                (!(isnan(obj->floatval)))) {
         *value = (long) obj->floatval;
-        if (*value != obj->floatval) {
+        if (*value != obj->floatval)
             ret = -2;
-        }
     } else {
         ret = -1;
     }
@@ -291,9 +290,8 @@ virXPathULongBase(const char *xpath,
     } else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
                (!(isnan(obj->floatval)))) {
         *value = (unsigned long) obj->floatval;
-        if (*value != obj->floatval) {
+        if (*value != obj->floatval)
             ret = -2;
-        }
     } else {
         ret = -1;
     }
@@ -408,9 +406,8 @@ virXPathULongLong(const char *xpath,
     } else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
                (!(isnan(obj->floatval)))) {
         *value = (unsigned long long) obj->floatval;
-        if (*value != obj->floatval) {
+        if (*value != obj->floatval)
             ret = -2;
-        }
     } else {
         ret = -1;
     }
@@ -455,9 +452,8 @@ virXPathLongLong(const char *xpath,
     } else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
                (!(isnan(obj->floatval)))) {
         *value = (long long) obj->floatval;
-        if (*value != obj->floatval) {
+        if (*value != obj->floatval)
             ret = -2;
-        }
     } else {
         ret = -1;
     }
@@ -655,9 +651,8 @@ catchXMLError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
     base = ctxt->input->base;

     /* skip backwards over any end-of-lines */
-    while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
+    while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r')))
         cur--;
-    }

     /* search backwards for beginning-of-line (to max buff size) */
     while ((cur > base) && (*(cur) != '\n') && (*(cur) != '\r'))
@@ -669,9 +664,8 @@ catchXMLError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)

     /* search forward for end-of-line (to max buff size) */
     /* copy selected text to our buffer */
-    while ((*cur != 0) && (*(cur) != '\n') && (*(cur) != '\r')) {
+    while ((*cur != 0) && (*(cur) != '\n') && (*(cur) != '\r'))
         virBufferAddChar(&buf, *cur++);
-    }

     /* create blank line with problem pointer */
     contextstr = virBufferContentAndReset(&buf);
-- 
2.1.3




More information about the libvir-list mailing list