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

[libvirt PATCH 06/19] Split declarations from initializations



Split those initializations that depend on a statement
above them.

Signed-off-by: Ján Tomko <jtomko redhat com>
---
 src/conf/network_conf.c              |  4 +++-
 src/conf/nwfilter_conf.c             |  5 ++++-
 src/lxc/lxc_controller.c             |  6 ++++--
 src/lxc/lxc_driver.c                 |  5 +++--
 src/qemu/qemu_command.c              |  8 ++++++--
 src/qemu/qemu_process.c              |  5 +++--
 src/rpc/virnetmessage.c              |  4 +++-
 src/rpc/virnetsocket.c               |  9 ++++++---
 src/util/virdaemon.c                 |  4 +++-
 src/util/virerror.c                  |  3 ++-
 src/util/virfile.c                   | 14 ++++++++++----
 src/util/virkeycode.c                |  4 +++-
 src/util/virnetlink.c                | 10 +++++++---
 src/util/virutil.c                   |  8 +++++---
 tests/nodedevmdevctltest.c           |  3 ++-
 tests/sockettest.c                   |  8 +++++---
 tests/virrotatingfiletest.c          |  7 +++++--
 tools/virsh-domain.c                 |  8 +++++---
 tools/virsh-volume.c                 |  5 +++--
 tools/wireshark/src/packet-libvirt.c |  3 ++-
 20 files changed, 84 insertions(+), 39 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index cd708e654f..d9a198a372 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1932,11 +1932,13 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
             addrMatch = false;
             for (j = 0; j < nips; j++) {
                 virNetworkIPDefPtr def2 = &def->ips[j];
+                int prefix;
+
                 if (VIR_SOCKET_ADDR_FAMILY(gateway)
                     != VIR_SOCKET_ADDR_FAMILY(&def2->address)) {
                     continue;
                 }
-                int prefix = virNetworkIPDefPrefix(def2);
+                prefix = virNetworkIPDefPrefix(def2);
                 virSocketAddrMaskByPrefix(&def2->address, prefix, &testAddr);
                 virSocketAddrMaskByPrefix(gateway, prefix, &testGw);
                 if (VIR_SOCKET_ADDR_VALID(&testAddr) &&
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 02722abc32..779da3dddb 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2864,10 +2864,13 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
     nwItemDesc *item;
 
     while (att[i].name) {
+        virNWFilterEntryItemFlags flags;
+
         VIR_WARNINGS_NO_CAST_ALIGN
         item = (nwItemDesc *)((char *)def + att[i].dataIdx);
         VIR_WARNINGS_RESET
-        virNWFilterEntryItemFlags flags = item->flags;
+
+        flags = item->flags;
         if ((flags & NWFILTER_ENTRY_ITEM_FLAG_EXISTS)) {
             if (!typeShown) {
                 virBufferAsprintf(buf, "<%s", type);
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index ae6b737b60..0a496fb788 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1490,11 +1490,12 @@ static int virLXCControllerPopulateDevices(virLXCControllerPtr ctrl)
     /* Populate /dev/ with a few important bits */
     for (i = 0; i < G_N_ELEMENTS(devs); i++) {
         g_autofree char *path = NULL;
+        dev_t dev;
 
         path = g_strdup_printf("/%s/%s.dev/%s", LXC_STATE_DIR, ctrl->def->name,
                                devs[i].path);
 
-        dev_t dev = makedev(devs[i].maj, devs[i].min);
+        dev = makedev(devs[i].maj, devs[i].min);
         if (mknod(path, S_IFCHR, dev) < 0 ||
             chmod(path, devs[i].mode)) {
             virReportSystemError(errno,
@@ -1990,11 +1991,12 @@ static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
 
     for (i = 0; i < def->nhostdevs; i ++) {
         virDomainHostdevDefPtr hdev = def->hostdevs[i];
+        virDomainHostdevCaps hdcaps;
 
         if (hdev->mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES)
             continue;
 
-        virDomainHostdevCaps hdcaps = hdev->source.caps;
+        hdcaps = hdev->source.caps;
 
         if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
             continue;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 1cdd6ee455..a530488dd2 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1440,6 +1440,7 @@ static virSecurityManagerPtr
 lxcSecurityInit(virLXCDriverConfigPtr cfg)
 {
     unsigned int flags = VIR_SECURITY_MANAGER_PRIVILEGED;
+    virSecurityManagerPtr mgr;
 
     VIR_INFO("lxcSecurityInit %s", cfg->securityDriverName);
 
@@ -1448,8 +1449,8 @@ lxcSecurityInit(virLXCDriverConfigPtr cfg)
     if (cfg->securityRequireConfined)
         flags |= VIR_SECURITY_MANAGER_REQUIRE_CONFINED;
 
-    virSecurityManagerPtr mgr = virSecurityManagerNew(cfg->securityDriverName,
-                                                      LXC_DRIVER_NAME, flags);
+    mgr = virSecurityManagerNew(cfg->securityDriverName,
+                                LXC_DRIVER_NAME, flags);
     if (!mgr)
         goto error;
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0655d8359d..fa33c4ab28 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4232,7 +4232,9 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
                          virDomainVideoDefPtr video,
                          virQEMUCapsPtr qemuCaps)
 {
+    const char *dev;
     const char *vgastr = qemuVideoTypeToString(video->type);
+
     if (!vgastr || STREQ(vgastr, "")) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("invalid model for video type '%s'"),
@@ -4253,7 +4255,7 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
      * See 'Graphics Devices' section in docs/qdev-device-use.txt in
      * QEMU repository.
      */
-    const char *dev = qemuDeviceVideoTypeToString(video->type);
+    dev = qemuDeviceVideoTypeToString(video->type);
 
     if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
         (video->vram || video->ram)) {
@@ -4935,9 +4937,11 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
         if (dev->data.nix.listen &&
             (flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) &&
             virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) {
+            int fd;
+
             if (qemuSecuritySetSocketLabel(secManager, (virDomainDefPtr)def) < 0)
                 return NULL;
-            int fd = qemuOpenChrChardevUNIXSocket(dev);
+            fd = qemuOpenChrChardevUNIXSocket(dev);
             if (qemuSecurityClearSocketLabel(secManager, (virDomainDefPtr)def) < 0) {
                 VIR_FORCE_CLOSE(fd);
                 return NULL;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7c312efd8b..ad4f190b7e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5018,11 +5018,12 @@ qemuProcessSetupRawIO(virQEMUDriverPtr driver,
     /* If rawio not already set, check hostdevs as well */
     if (!rawio) {
         for (i = 0; i < vm->def->nhostdevs; i++) {
+            virDomainHostdevSubsysSCSIPtr scsisrc;
+
             if (!virHostdevIsSCSIDevice(vm->def->hostdevs[i]))
                 continue;
 
-            virDomainHostdevSubsysSCSIPtr scsisrc =
-                &vm->def->hostdevs[i]->source.subsys.u.scsi;
+            scsisrc = &vm->def->hostdevs[i]->source.subsys.u.scsi;
             if (scsisrc->rawio == VIR_TRISTATE_BOOL_YES) {
                 rawio = true;
                 break;
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index 9d2a8a6d7d..c4ddafc01d 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -511,6 +511,8 @@ int virNetMessageEncodePayloadEmpty(virNetMessagePtr msg)
 
 void virNetMessageSaveError(virNetMessageErrorPtr rerr)
 {
+    virErrorPtr verr;
+
     /* This func may be called several times & the first
      * error is the one we want because we don't want
      * cleanup code overwriting the first one.
@@ -519,7 +521,7 @@ void virNetMessageSaveError(virNetMessageErrorPtr rerr)
         return;
 
     memset(rerr, 0, sizeof(*rerr));
-    virErrorPtr verr = virGetLastError();
+    verr = virGetLastError();
     if (verr) {
         rerr->code = verr->code;
         rerr->domain = verr->domain;
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 977d2875fe..f3aba01fd5 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -325,6 +325,8 @@ int virNetSocketNewListenTCP(const char *nodename,
     int bindErrno = 0;
     virSocketAddr tmp_addr;
     int port = 0;
+    int e;
+    struct addrinfo *runp;
 
     *retsocks = NULL;
     *nretsocks = 0;
@@ -346,7 +348,7 @@ int virNetSocketNewListenTCP(const char *nodename,
           virSocketAddrIsWildcard(&tmp_addr)))
         hints.ai_flags |= AI_ADDRCONFIG;
 
-    int e = getaddrinfo(nodename, service, &hints, &ai);
+    e = getaddrinfo(nodename, service, &hints, &ai);
     if (e != 0) {
         virReportError(VIR_ERR_SYSTEM_ERROR,
                        _("Unable to resolve address '%s' service '%s': %s"),
@@ -354,7 +356,7 @@ int virNetSocketNewListenTCP(const char *nodename,
         return -1;
     }
 
-    struct addrinfo *runp = ai;
+    runp = ai;
     while (runp) {
         virSocketAddr addr;
 
@@ -587,6 +589,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
     virSocketAddr remoteAddr;
     struct addrinfo *runp;
     int savedErrno = ENOENT;
+    int e;
 
     *retsock = NULL;
 
@@ -598,7 +601,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
     hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED;
     hints.ai_socktype = SOCK_STREAM;
 
-    int e = getaddrinfo(nodename, service, &hints, &ai);
+    e = getaddrinfo(nodename, service, &hints, &ai);
     if (e != 0) {
         virReportError(VIR_ERR_SYSTEM_ERROR,
                        _("Unable to resolve address '%s' service '%s': %s"),
diff --git a/src/util/virdaemon.c b/src/util/virdaemon.c
index 31cc24e703..a02665dce8 100644
--- a/src/util/virdaemon.c
+++ b/src/util/virdaemon.c
@@ -43,10 +43,12 @@ int
 virDaemonForkIntoBackground(const char *argv0)
 {
     int statuspipe[2];
+    pid_t pid;
+
     if (virPipeQuiet(statuspipe) < 0)
         return -1;
 
-    pid_t pid = fork();
+    pid = fork();
     switch (pid) {
     case 0:
         {
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 774c36bca3..507a29f50f 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -1335,13 +1335,14 @@ void virReportSystemErrorFull(int domcode,
 
     if (fmt) {
         va_list args;
+        size_t len;
         int n;
 
         va_start(args, fmt);
         n = g_vsnprintf(msgDetailBuf, sizeof(msgDetailBuf), fmt, args);
         va_end(args);
 
-        size_t len = strlen(errnoDetail);
+        len = strlen(errnoDetail);
         if (0 <= n && n + 2 + len < sizeof(msgDetailBuf)) {
           strcpy(msgDetailBuf + n, ": ");
           n += 2;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 6ada3a708c..59bdbc121b 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1412,13 +1412,16 @@ virFileReadLimFD(int fd, int maxlen, char **buf)
 int
 virFileReadAll(const char *path, int maxlen, char **buf)
 {
-    int fd = open(path, O_RDONLY);
+    int fd;
+    int len;
+
+    fd = open(path, O_RDONLY);
     if (fd < 0) {
         virReportSystemError(errno, _("Failed to open file '%s'"), path);
         return -1;
     }
 
-    int len = virFileReadLimFD(fd, maxlen, buf);
+    len = virFileReadLimFD(fd, maxlen, buf);
     VIR_FORCE_CLOSE(fd);
     if (len < 0) {
         virReportSystemError(errno, _("Failed to read file '%s'"), path);
@@ -1431,11 +1434,14 @@ virFileReadAll(const char *path, int maxlen, char **buf)
 int
 virFileReadAllQuiet(const char *path, int maxlen, char **buf)
 {
-    int fd = open(path, O_RDONLY);
+    int fd;
+    int len;
+
+    fd = open(path, O_RDONLY);
     if (fd < 0)
         return -errno;
 
-    int len = virFileReadLimFD(fd, maxlen, buf);
+    len = virFileReadLimFD(fd, maxlen, buf);
     VIR_FORCE_CLOSE(fd);
     if (len < 0)
         return -errno;
diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c
index 1475f69b84..8ca1b573d3 100644
--- a/src/util/virkeycode.c
+++ b/src/util/virkeycode.c
@@ -88,11 +88,13 @@ int virKeycodeValueFromString(virKeycodeSet codeset,
     size_t i;
 
     for (i = 0; i < VIR_KEYMAP_ENTRY_MAX; i++) {
+        const char *name;
+
         if (!virKeymapNames[codeset] ||
             !virKeymapValues[codeset])
             continue;
 
-        const char *name = virKeymapNames[codeset][i];
+        name = virKeymapNames[codeset][i];
 
         if (name && STREQ_NULLABLE(name, keyname))
             return virKeymapValues[codeset][i];
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index d23ed95b78..652ed2c1c6 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -817,10 +817,12 @@ virNetlinkEventServerUnlock(virNetlinkEventSrvPrivatePtr driver)
 static int
 virNetlinkEventRemoveClientPrimitive(size_t i, unsigned int protocol)
 {
+    virNetlinkEventRemoveCallback removeCB;
+
     if (protocol >= MAX_LINKS)
         return -EINVAL;
 
-    virNetlinkEventRemoveCallback removeCB = server[protocol]->handles[i].removeCB;
+    removeCB = server[protocol]->handles[i].removeCB;
 
     if (removeCB) {
         (removeCB)(server[protocol]->handles[i].watch,
@@ -890,11 +892,13 @@ virNetlinkEventCallback(int watch,
 int
 virNetlinkEventServiceStop(unsigned int protocol)
 {
+    virNetlinkEventSrvPrivatePtr srv;
+    size_t i;
+
     if (protocol >= MAX_LINKS)
         return -EINVAL;
 
-    virNetlinkEventSrvPrivatePtr srv = server[protocol];
-    size_t i;
+    srv = server[protocol];
 
     VIR_INFO("stopping netlink event service");
 
diff --git a/src/util/virutil.c b/src/util/virutil.c
index ff664ea778..8639176fdc 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -371,6 +371,7 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
     int idx = 0;
     static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd", "ubd"};
     size_t i;
+    size_t n_digits;
 
     for (i = 0; i < G_N_ELEMENTS(drive_prefix); i++) {
         if (STRPREFIX(name, drive_prefix[i])) {
@@ -391,8 +392,8 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
         ptr++;
     }
 
-    /* Count the trailing digits.  */
-    size_t n_digits = strspn(ptr, "0123456789");
+    /* Count the trailing digits */
+    n_digits = strspn(ptr, "0123456789");
     if (ptr[n_digits] != '\0')
         return -1;
 
@@ -1911,10 +1912,11 @@ static int
 virPipeImpl(int fds[2], bool nonblock, bool errreport)
 {
 #ifdef HAVE_PIPE2
+    int rv;
     int flags = O_CLOEXEC;
     if (nonblock)
         flags |= O_NONBLOCK;
-    int rv = pipe2(fds, flags);
+    rv = pipe2(fds, flags);
 #else /* !HAVE_PIPE2 */
 # ifdef WIN32
     int rv = _pipe(fds, 4096, _O_BINARY);
diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c
index 9780553a3a..57c1ad4f46 100644
--- a/tests/nodedevmdevctltest.c
+++ b/tests/nodedevmdevctltest.c
@@ -203,10 +203,11 @@ fakeParentDevice(void)
 static int
 addDevice(virNodeDeviceDefPtr def)
 {
+    virNodeDeviceObjPtr obj;
     if (!def)
         return -1;
 
-    virNodeDeviceObjPtr obj = virNodeDeviceObjListAssignDef(driver->devs, def);
+    obj = virNodeDeviceObjListAssignDef(driver->devs, def);
 
     if (!obj) {
         virNodeDeviceDefFree(def);
diff --git a/tests/sockettest.c b/tests/sockettest.c
index 29a565de40..a3c27421fc 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -90,6 +90,7 @@ testRange(const char *saddrstr, const char *eaddrstr,
     virSocketAddr saddr;
     virSocketAddr eaddr;
     virSocketAddr netaddr;
+    int gotsize;
 
     if (virSocketAddrParse(&saddr, saddrstr, AF_UNSPEC) < 0)
         return -1;
@@ -98,8 +99,8 @@ testRange(const char *saddrstr, const char *eaddrstr,
     if (netstr && virSocketAddrParse(&netaddr, netstr, AF_UNSPEC) < 0)
         return -1;
 
-    int gotsize = virSocketAddrGetRange(&saddr, &eaddr,
-                                        netstr ? &netaddr : NULL, prefix);
+    gotsize = virSocketAddrGetRange(&saddr, &eaddr,
+                                    netstr ? &netaddr : NULL, prefix);
     VIR_DEBUG("Size want %d vs got %d", size, gotsize);
     if (pass) {
         /* fail if virSocketAddrGetRange returns failure, or unexpected size */
@@ -136,6 +137,7 @@ static int testNetmask(const char *addr1str, const char *addr2str,
     virSocketAddr addr1;
     virSocketAddr addr2;
     virSocketAddr netmask;
+    int ret;
 
     if (virSocketAddrParse(&addr1, addr1str, AF_UNSPEC) < 0)
         return -1;
@@ -144,7 +146,7 @@ static int testNetmask(const char *addr1str, const char *addr2str,
     if (virSocketAddrParse(&netmask, netmaskstr, AF_UNSPEC) < 0)
         return -1;
 
-    int ret = virSocketAddrCheckNetmask(&addr1, &addr2, &netmask);
+    ret = virSocketAddrCheckNetmask(&addr1, &addr2, &netmask);
 
     if (ret <= 0) {
         return pass ? -1 : 0;
diff --git a/tests/virrotatingfiletest.c b/tests/virrotatingfiletest.c
index df392f374e..f8dd7daefe 100644
--- a/tests/virrotatingfiletest.c
+++ b/tests/virrotatingfiletest.c
@@ -124,9 +124,12 @@ static int testRotatingFileInitOne(const char *filename,
         VIR_DEBUG("Deleting %s", filename);
         unlink(filename);
     } else {
-        VIR_DEBUG("Creating %s size %zu", filename, (size_t)size);
         char buf[1024];
-        int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
+        int fd;
+
+        VIR_DEBUG("Creating %s size %zu", filename, (size_t)size);
+
+        fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
         if (fd < 0) {
             fprintf(stderr, "Cannot create %s\n", filename);
             return -1;
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 7ce848f92e..29fa3f607e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1757,6 +1757,7 @@ virshBlockJobWaitInit(vshControl *ctl,
                       unsigned int timeout,
                       bool async_abort)
 {
+    virConnectDomainEventGenericCallback cb;
     virshBlockJobWaitDataPtr ret;
     virshControlPtr priv = ctl->privData;
 
@@ -1774,8 +1775,7 @@ virshBlockJobWaitInit(vshControl *ctl,
 
     ret->status = -1;
 
-    virConnectDomainEventGenericCallback cb =
-        VIR_DOMAIN_EVENT_CALLBACK(virshBlockJobStatusHandler);
+    cb = VIR_DOMAIN_EVENT_CALLBACK(virshBlockJobStatusHandler);
 
     if ((ret->cb_id = virConnectDomainEventRegisterAny(priv->conn, dom,
                                                        VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
@@ -7117,12 +7117,14 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen,
             return NULL;
         virBitmapSetAll(map);
     } else {
+        int lastcpu;
+
         if (virBitmapParse(cpulist, &map, 1024) < 0 ||
             virBitmapIsAllClear(map)) {
             vshError(ctl, _("Invalid cpulist '%s'"), cpulist);
             goto cleanup;
         }
-        int lastcpu = virBitmapLastSetBit(map);
+        lastcpu = virBitmapLastSetBit(map);
         if (lastcpu >= maxcpu) {
             vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"),
                      lastcpu, cpulist, maxcpu);
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index e04e2db096..ae7c643d3b 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -275,12 +275,14 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
 
     /* Convert the snapshot parameters into backingStore XML */
     if (snapshotStrVol) {
+        virStorageVolPtr snapVol;
+        char *snapshotStrVolPath;
         /* Lookup snapshot backing volume.  Try the backing-vol
          *  parameter as a name */
         vshDebug(ctl, VSH_ERR_DEBUG,
                  "%s: Look up backing store volume '%s' as name\n",
                  cmd->def->name, snapshotStrVol);
-        virStorageVolPtr snapVol = virStorageVolLookupByName(pool, snapshotStrVol);
+        snapVol = virStorageVolLookupByName(pool, snapshotStrVol);
         if (snapVol)
                 vshDebug(ctl, VSH_ERR_DEBUG,
                          "%s: Backing store volume found using '%s' as name\n",
@@ -315,7 +317,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
         }
 
-        char *snapshotStrVolPath;
         if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
             virStorageVolFree(snapVol);
             goto cleanup;
diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/packet-libvirt.c
index 2b499d2cf2..89dd18080e 100644
--- a/tools/wireshark/src/packet-libvirt.c
+++ b/tools/wireshark/src/packet-libvirt.c
@@ -428,11 +428,12 @@ dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
     if (status == VIR_NET_OK) {
         const vir_dissector_index_t *pds = get_program_data(prog, VIR_PROGRAM_DISSECTORS);
         const gsize *len = get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN);
+        vir_xdr_dissector_t xd;
 
         if (!len)
             goto unknown;
 
-        vir_xdr_dissector_t xd = find_payload_dissector(proc, type, pds, *len);
+        xd = find_payload_dissector(proc, type, pds, *len);
         if (xd == NULL)
             goto unknown;
         dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, xd);
-- 
2.26.2


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