[libvirt PATCH 05/19] Move declarations before statements

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

 



Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/bhyve/bhyve_parse_command.c     |  3 ++-
 src/conf/domain_conf.c              |  9 ++++++---
 src/conf/network_conf.c             |  3 ++-
 src/conf/virstorageobj.c            |  3 ++-
 src/nwfilter/nwfilter_learnipaddr.c |  2 +-
 src/openvz/openvz_conf.c            | 12 ++++++------
 src/qemu/qemu_process.c             |  5 +++--
 src/remote/remote_driver.c          |  3 +--
 src/storage/storage_util.c          |  2 +-
 src/util/virdbus.c                  |  2 +-
 src/util/virqemu.c                  |  2 +-
 src/vbox/vbox_common.c              | 21 +++++++++++----------
 src/vbox/vbox_snapshot_conf.c       |  8 ++++++--
 src/vz/vz_driver.c                  | 10 +++++-----
 tests/commandhelper.c               |  5 ++---
 tests/eventtest.c                   |  5 +++--
 tests/vircgroupmock.c               |  8 ++++++--
 tools/virsh-domain.c                |  4 +++-
 tools/virsh-interface.c             |  3 ++-
 tools/virsh-network.c               |  3 ++-
 tools/virsh-nodedev.c               |  2 +-
 tools/virsh-util.c                  |  3 ++-
 tools/virt-host-validate-common.c   |  3 ++-
 23 files changed, 71 insertions(+), 50 deletions(-)

diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index b2d2280872..67ca0ddfa3 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -171,12 +171,13 @@ bhyveCommandLineToArgv(const char *nativeConfig,
     }
 
     for (i = 0; i < line_count; i++) {
-        curr = lines[i];
         size_t j;
         char **arglist = NULL;
         size_t args_count = 0;
         size_t args_alloc = 0;
 
+        curr = lines[i];
+
         /* iterate over each line, splitting on sequences of ' '. This code is
          * adapted from qemu/qemu_parse_command.c. */
         while (curr && *curr != '\0') {
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 69e0439e7e..570812cefb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2845,12 +2845,13 @@ void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def)
 
 void virDomainSoundDefFree(virDomainSoundDefPtr def)
 {
+    size_t i;
+
     if (!def)
         return;
 
     virDomainDeviceInfoClear(&def->info);
 
-    size_t i;
     for (i = 0; i < def->ncodecs; i++)
         virDomainSoundCodecDefFree(def->codecs[i]);
     VIR_FREE(def->codecs);
@@ -3222,10 +3223,11 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def)
 static void
 virDomainClockDefClear(virDomainClockDefPtr def)
 {
+    size_t i;
+
     if (def->offset == VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE)
         VIR_FREE(def->data.timezone);
 
-    size_t i;
     for (i = 0; i < def->ntimers; i++)
         VIR_FREE(def->timers[i]);
     VIR_FREE(def->timers);
@@ -16585,9 +16587,10 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
                                  virDomainMemoryDefPtr def)
 {
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
-    ctxt->node = node;
     g_autofree char *nodemask = NULL;
 
+    ctxt->node = node;
+
     switch ((virDomainMemoryModel) def->model) {
     case VIR_DOMAIN_MEMORY_MODEL_DIMM:
         if (virDomainParseMemory("./pagesize", "./pagesize/@unit", ctxt,
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 4221623c37..cd708e654f 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2534,9 +2534,10 @@ virNetworkDefFormatBuf(virBufferPtr buf,
 
     if (def->forward.type != VIR_NETWORK_FORWARD_NONE) {
         const char *dev = NULL;
+        const char *mode = virNetworkForwardTypeToString(def->forward.type);
+
         if (!def->forward.npfs)
             dev = virNetworkDefForwardIf(def, 0);
-        const char *mode = virNetworkForwardTypeToString(def->forward.type);
 
         if (!mode) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index f3c54d0c52..1c7d615a7a 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -1114,9 +1114,10 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
         /* UUID does not match, but if a name matches, refuse it */
         obj = virStoragePoolObjFindByNameLocked(pools, def->name);
         if (obj) {
+            char uuidstr[VIR_UUID_STRING_BUFLEN];
+
             virObjectLock(obj);
 
-            char uuidstr[VIR_UUID_STRING_BUFLEN];
             virUUIDFormat(obj->def->uuid, uuidstr);
             virReportError(VIR_ERR_OPERATION_FAILED,
                            _("pool '%s' already exists with uuid %s"),
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index c6497450eb..c28b12f2f0 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -626,12 +626,12 @@ learnIPAddressThread(void *arg)
         pcap_close(handle);
 
     if (req->status == 0) {
+        g_autofree char *inetaddr = NULL;
         int ret;
         virSocketAddr sa;
         sa.len = sizeof(sa.data.inet4);
         sa.data.inet4.sin_family = AF_INET;
         sa.data.inet4.sin_addr.s_addr = vmaddr;
-        g_autofree char *inetaddr = NULL;
 
         /* It is necessary to unlock interface here to avoid updateMutex and
          * interface ordering deadlocks. Otherwise we are going to
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index db3df5ed5a..6d54123a35 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -233,16 +233,16 @@ openvzReadNetworkConf(virDomainDefPtr def,
     } else if (ret > 0) {
         token = strtok_r(temp, ";", &saveptr);
         while (token != NULL) {
-            /* add new device to list */
-            if (VIR_ALLOC(net) < 0)
-                goto error;
-
-            net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
-
             char *p = token;
             char cpy_temp[32];
             int len;
 
+            /* add new device to list */
+            if (VIR_ALLOC(net) < 0)
+                goto error;
+
+            net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+
             /* parse string */
             do {
                 char *next = strchr(p, ',');
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 812220769d..7c312efd8b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -522,9 +522,10 @@ qemuProcessShutdownOrReboot(virQEMUDriverPtr driver,
 
     if (priv->fakeReboot) {
         g_autofree char *name = g_strdup_printf("reboot-%s", vm->def->name);
-        qemuDomainSetFakeReboot(driver, vm, false);
-        virObjectRef(vm);
         virThread th;
+
+        qemuDomainSetFakeReboot(driver, vm, false);
+        virObjectRef(vm);
         if (virThreadCreateFull(&th,
                                 false,
                                 qemuProcessFakeReboot,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 0331060a2d..2402f73475 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -957,6 +957,7 @@ doRemoteOpen(virConnectPtr conn,
     bool tty = true;
 #endif
     int mode;
+    size_t i;
 
     if (inside_daemon && !conn->uri->server) {
         mode = REMOTE_DRIVER_MODE_DIRECT;
@@ -1014,8 +1015,6 @@ doRemoteOpen(virConnectPtr conn,
      * feasibly it might contain variables needed by the real driver,
      * although that won't be the case for now).
      */
-    size_t i;
-
     if (conn->uri) {
         for (i = 0; i < conn->uri->paramsCount; i++) {
             virURIParamPtr var = &conn->uri->params[i];
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index f7c09e3375..4752ab78a3 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -192,8 +192,8 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
          * blocks */
         amtleft = amtread;
         do {
-            interval = ((wbytes > amtleft) ? amtleft : wbytes);
             int offset = amtread - amtleft;
+            interval = ((wbytes > amtleft) ? amtleft : wbytes);
 
             if (want_sparse && memcmp(buf+offset, zerobuf, interval) == 0) {
                 if (lseek(fd, interval, SEEK_CUR) < 0) {
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 77691cd2b0..f512031b42 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -999,6 +999,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
         case DBUS_TYPE_SIGNATURE:
             do {
                 char **x;
+                char *s;
                 if (arrayref) {
                     char ***xptrptr = arrayptr;
                     if (VIR_EXPAND_N(*xptrptr, *narrayptr, 1) < 0)
@@ -1008,7 +1009,6 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
                 } else {
                     x = (char **)va_arg(args, char **);
                 }
-                char *s;
                 dbus_message_iter_get_basic(iter, &s);
                 *x = g_strdup(s);
                 VIR_DEBUG("Read basic type 'char *' varg 'char **'"
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 20cb09d878..25d6fd35c5 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -94,9 +94,9 @@ virQEMUBuildCommandLineJSONArrayNumbered(const char *key,
     size_t i;
 
     for (i = 0; i < virJSONValueArraySize(array); i++) {
-        member = virJSONValueArrayGet((virJSONValuePtr) array, i);
         g_autofree char *prefix = NULL;
 
+        member = virJSONValueArrayGet((virJSONValuePtr) array, i);
         prefix = g_strdup_printf("%s.%zu", key, i);
 
         if (virQEMUBuildCommandLineJSONRecurse(prefix, member, buf, skipKey, onOff,
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 1adafa1e70..bae62f6967 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -653,6 +653,7 @@ static int
 vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED)
 {
     vboxDriverPtr data = conn->privateData;
+    ISystemProperties *systemProperties = NULL;
     PRUint32 maxCPUCount = 0;
     int ret = -1;
 
@@ -662,7 +663,6 @@ vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED)
     /* VirtualBox Supports only hvm and thus the type passed to it
      * has no meaning, setting it to G_GNUC_UNUSED
      */
-    ISystemProperties *systemProperties = NULL;
 
     gVBoxAPI.UIVirtualBox.GetSystemProperties(data->vboxObj, &systemProperties);
     if (!systemProperties)
@@ -4603,6 +4603,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
     char *nameTmpUse = NULL;
     bool snapshotFileExists = false;
     bool needToChangeStorageController = false;
+    char uuidtmp[VIR_UUID_STRING_BUFLEN];
     int ret = -1;
 
     if (!data->vboxObj)
@@ -4782,6 +4783,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
         char *parentUuid = NULL;
         virVBoxSnapshotConfHardDiskPtr readOnlyDisk = NULL;
         vboxIID iid, parentiid;
+        IMedium *parentReadOnlyMedium = NULL;
 
         VBOX_IID_INITIALIZE(&iid);
         VBOX_IID_INITIALIZE(&parentiid);
@@ -4831,7 +4833,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
         VBOX_UTF16_FREE(formatUtf);
 
         /* This disk is already in the media registry */
-        IMedium *parentReadOnlyMedium = NULL;
         rc = gVBoxAPI.UIMedium.GetParent(readOnlyMedium, &parentReadOnlyMedium);
         if (NS_FAILED(rc)) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -4965,7 +4966,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
     if (virUUIDGenerate(snapshotUuid) < 0)
         goto cleanup;
 
-    char uuidtmp[VIR_UUID_STRING_BUFLEN];
     virUUIDFormat(snapshotUuid, uuidtmp);
     newSnapshotPtr->uuid = g_strdup(uuidtmp);
 
@@ -5176,6 +5176,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
             }
         }
     } else {
+        char *snapshotContent;
         /* Create a "fake" disk to avoid corrupting children snapshot disks. */
         for (it = 0; it < def->parent.dom->ndisks; it++) {
             IMedium *medium = NULL;
@@ -5190,6 +5191,8 @@ vboxSnapshotRedefine(virDomainPtr dom,
             char *format = NULL;
             char *tmp = NULL;
             vboxIID iid, parentiid;
+            IProgress *progress = NULL;
+            PRUint32 tab[1];
 
             VBOX_IID_INITIALIZE(&iid);
             VBOX_IID_INITIALIZE(&parentiid);
@@ -5235,8 +5238,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
                 goto cleanup;
             }
 
-            IProgress *progress = NULL;
-            PRUint32 tab[1];
             tab[0] = MediumVariant_Diff;
             gVBoxAPI.UIMedium.CreateDiffStorage(medium, newMedium, 1, tab, &progress);
 
@@ -5320,9 +5321,9 @@ vboxSnapshotRedefine(virDomainPtr dom,
         VIR_FREE(currentSnapshotXmlFilePath);
         currentSnapshotXmlFilePath = g_strdup_printf("%s%s.xml",
                                                      machineLocationPath, snapshotMachineDesc->currentSnapshot);
-        char *snapshotContent = virDomainSnapshotDefFormat(NULL, def,
-                                                           data->xmlopt,
-                                                           VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE);
+        snapshotContent = virDomainSnapshotDefFormat(NULL, def,
+                                                     data->xmlopt,
+                                                     VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE);
         if (snapshotContent == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Unable to get snapshot content"));
@@ -6947,6 +6948,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
                 char *tmp = NULL;
                 vboxIID iid, parentiid;
                 resultCodeUnion resultCode;
+                PRUint32 tab[1];
 
                 VBOX_IID_INITIALIZE(&iid);
                 VBOX_IID_INITIALIZE(&parentiid);
@@ -7004,7 +7006,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
                 VBOX_UTF16_FREE(formatUtf16);
                 VBOX_UTF16_FREE(newLocation);
 
-                PRUint32 tab[1];
                 tab[0] = MediumVariant_Diff;
                 gVBoxAPI.UIMedium.CreateDiffStorage(medium, newMedium, 1, tab, &progress);
 
@@ -7536,12 +7537,12 @@ vboxConnectListAllDomains(virConnectPtr conn,
 
     for (i = 0; i < machines.count; i++) {
         IMachine *machine = machines.items[i];
+        PRBool isAccessible = PR_FALSE;
         int id = -1;
 
         if (!machine)
             continue;
 
-        PRBool isAccessible = PR_FALSE;
         gVBoxAPI.UIMachine.GetAccessible(machine, &isAccessible);
 
         if (!isAccessible)
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 6b95311328..ee644e1e2d 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -1286,8 +1286,10 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char *filePath,
 
     for (i = 0; i < nodeSize; i++) {
         xmlNodePtr node = nodes[i];
+        xmlNodePtr sourceNode;
+
         xPathContext->node = node;
-        xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
+        sourceNode = virXPathNode("./source", xPathContext);
         if (sourceNode)
             ret[i] = virXMLPropString(sourceNode, "file");
     }
@@ -1347,8 +1349,10 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath,
 
     for (i = 0; i < nodeSize; i++) {
         xmlNodePtr node = nodes[i];
+        xmlNodePtr sourceNode;
+
         xPathContext->node = node;
-        xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
+        sourceNode = virXPathNode("./source", xPathContext);
         if (sourceNode)
             ret[i] = virXMLPropString(sourceNode, "file");
     }
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 1f9c4c79c0..40b1828eb2 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -112,6 +112,8 @@ vzBuildCapabilities(void)
     };
     size_t i, j, k;
 
+    G_STATIC_ASSERT(G_N_ELEMENTS(archs) == G_N_ELEMENTS(emulators));
+
     if ((caps = virCapabilitiesNew(virArchFromHost(),
                                    false, false)) == NULL)
         return NULL;
@@ -122,8 +124,6 @@ vzBuildCapabilities(void)
     if (virCapabilitiesInitCaches(caps) < 0)
         goto error;
 
-    G_STATIC_ASSERT(G_N_ELEMENTS(archs) == G_N_ELEMENTS(emulators));
-
     for (i = 0; i < G_N_ELEMENTS(ostypes); i++)
         for (j = 0; j < G_N_ELEMENTS(archs); j++)
             for (k = 0; k < G_N_ELEMENTS(emulators); k++)
@@ -220,12 +220,12 @@ vzConnectGetCapabilities(virConnectPtr conn)
 static int
 vzDomainDefAddDefaultInputDevices(virDomainDefPtr def)
 {
-    if (def->ngraphics == 0)
-        return 0;
-
     int bus = IS_CT(def) ? VIR_DOMAIN_INPUT_BUS_PARALLELS :
                            VIR_DOMAIN_INPUT_BUS_PS2;
 
+    if (def->ngraphics == 0)
+        return 0;
+
     if (virDomainDefMaybeAddInput(def,
                                   VIR_DOMAIN_INPUT_TYPE_MOUSE,
                                   bus) < 0)
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index b366483771..05f577730f 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -74,6 +74,8 @@ int main(int argc, char **argv) {
     char c;
     bool daemonize_check = false;
     size_t daemonize_retries = 3;
+    char buf[1024];
+    ssize_t got;
 
     if (!log)
         return ret;
@@ -167,9 +169,6 @@ int main(int argc, char **argv) {
         usleep(100*1000);
     }
 
-    char buf[1024];
-    ssize_t got;
-
     fprintf(stdout, "BEGIN STDOUT\n");
     fflush(stdout);
     fprintf(stderr, "BEGIN STDERR\n");
diff --git a/tests/eventtest.c b/tests/eventtest.c
index 06b5e7b20c..4a23bd6e62 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -89,10 +89,11 @@ G_GNUC_PRINTF(3, 4)
 testEventReport(const char *name, bool failed, const char *msg, ...)
 {
     va_list vargs;
-    va_start(vargs, msg);
     char *str = NULL;
     struct testEventResultData data;
 
+    va_start(vargs, msg);
+
     if (msg)
         str = g_strdup_vprintf(msg, vargs);
 
@@ -325,6 +326,7 @@ mymain(void)
     size_t i;
     pthread_t eventThread;
     char one = '1';
+    char *debugEnv = getenv("LIBVIRT_DEBUG");
 
     for (i = 0; i < NUM_FDS; i++) {
         if (virPipeQuiet(handles[i].pipeFD) < 0) {
@@ -333,7 +335,6 @@ mymain(void)
         }
     }
 
-    char *debugEnv = getenv("LIBVIRT_DEBUG");
     if (debugEnv && *debugEnv &&
         (virLogSetDefaultPriority(virLogParseDefaultPriority(debugEnv)) < 0)) {
         fprintf(stderr, "Invalid log level setting.\n");
diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c
index 66b8c01852..2da60f886a 100644
--- a/tests/vircgroupmock.c
+++ b/tests/vircgroupmock.c
@@ -467,8 +467,10 @@ int access(const char *path, int mode)
     init_syms();
 
     if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
-        init_sysfs();
         char *newpath;
+
+        init_sysfs();
+
         if (asprintf(&newpath, "%s%s",
                      fakesysfscgroupdir,
                      path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
@@ -534,8 +536,10 @@ int mkdir(const char *path, mode_t mode)
     init_syms();
 
     if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
-        init_sysfs();
         char *newpath;
+
+        init_sysfs();
+
         if (asprintf(&newpath, "%s%s",
                      fakesysfscgroupdir,
                      path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 286cf79671..7ce848f92e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3794,8 +3794,10 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
             goto error;
 
         for (i = 0; i < nvol_nodes; i++) {
-            ctxt->node = vol_nodes[i];
             virshUndefineVolume vol;
+
+            ctxt->node = vol_nodes[i];
+
             VIR_FREE(source);
             VIR_FREE(target);
             VIR_FREE(pool);
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index b8e424091d..a6b52726c9 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -49,8 +49,9 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
     const char *n = NULL;
     bool is_mac = false;
     virMacAddr dummy;
+    virshControlPtr priv = ctl->privData;
+
     virCheckFlags(VIRSH_BYNAME | VIRSH_BYMAC, NULL);
-    virshControlPtr priv = ctl->privData;
 
     if (!optname)
        optname = "interface";
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index f2a5d09732..f0f5358625 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -69,8 +69,9 @@ virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
     virNetworkPtr network = NULL;
     const char *n = NULL;
     const char *optname = "network";
+    virshControlPtr priv = ctl->privData;
+
     virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL);
-    virshControlPtr priv = ctl->privData;
 
     if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)
         return NULL;
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index e576b3c847..e9414f429f 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -285,6 +285,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
         char **caps = NULL;
         int ncaps = 0;
         bool match = false;
+        size_t j, k;
 
         device = list->devices[i];
 
@@ -305,7 +306,6 @@ virshNodeDeviceListCollect(vshControl *ctl,
         /* Check if the device's capability matches with provided
          * capabilities.
          */
-        size_t j, k;
         for (j = 0; j < ncaps; j++) {
             for (k = 0; k < ncapnames; k++) {
                 if (STREQ(caps[j], capnames[k])) {
diff --git a/tools/virsh-util.c b/tools/virsh-util.c
index 932d6d0849..3b375c60f1 100644
--- a/tools/virsh-util.c
+++ b/tools/virsh-util.c
@@ -32,8 +32,9 @@ virshLookupDomainInternal(vshControl *ctl,
 {
     virDomainPtr dom = NULL;
     int id;
+    virshControlPtr priv = ctl->privData;
+
     virCheckFlags(VIRSH_BYID | VIRSH_BYUUID | VIRSH_BYNAME, NULL);
-    virshControlPtr priv = ctl->privData;
 
     /* try it by ID */
     if (flags & VIRSH_BYID) {
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index f68c9c7c96..e0e22a133a 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -172,9 +172,10 @@ int virHostValidateNamespace(const char *hvname,
                              virHostValidateLevel level,
                              const char *hint)
 {
-    virHostMsgCheck(hvname, "for namespace %s", ns_name);
     char nspath[100];
 
+    virHostMsgCheck(hvname, "for namespace %s", ns_name);
+
     g_snprintf(nspath, sizeof(nspath), "/proc/self/ns/%s", ns_name);
 
     if (access(nspath, F_OK) < 0) {
-- 
2.26.2




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

  Powered by Linux