From 92047567cf74032f62bf0bc6b24bb35a1dde6154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 23 Sep 2020 19:28:31 +0200 Subject: [PATCH] Reduce scope of some variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ján Tomko Reviewed-by: Martin Kletzander --- src/libvirt-host.c | 4 +--- src/node_device/node_device_driver.c | 3 ++- src/storage/storage_backend_mpath.c | 3 +-- src/storage/storage_util.c | 6 ++---- tools/virsh-pool.c | 3 ++- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 07d13585f4..58622d415d 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1352,8 +1352,6 @@ virConnectSetKeepAlive(virConnectPtr conn, int interval, unsigned int count) { - int ret = -1; - VIR_DEBUG("conn=%p, interval=%d, count=%u", conn, interval, count); virResetLastError(); @@ -1361,7 +1359,7 @@ virConnectSetKeepAlive(virConnectPtr conn, virCheckConnectReturn(conn, -1); if (conn->driver->connectSetKeepAlive) { - ret = conn->driver->connectSetKeepAlive(conn, interval, count); + int ret = conn->driver->connectSetKeepAlive(conn, interval, count); if (ret < 0) goto error; return ret; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index f4b140bef4..f5ea973c7a 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -747,7 +747,6 @@ nodeDeviceCreateXML(virConnectPtr conn, g_autoptr(virNodeDeviceDef) def = NULL; g_autofree char *wwnn = NULL; g_autofree char *wwpn = NULL; - int parent_host = -1; virNodeDevicePtr device = NULL; const char *virt_type = NULL; @@ -765,6 +764,8 @@ nodeDeviceCreateXML(virConnectPtr conn, return NULL; if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_SCSI_HOST)) { + int parent_host; + if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) return NULL; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index fffc0f86b7..f474ab32a9 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -151,13 +151,12 @@ static int virStorageBackendCreateVols(virStoragePoolObjPtr pool, struct dm_names *names) { - int is_mpath = 0; uint32_t minor = -1; uint32_t next; g_autofree char *map_device = NULL; do { - is_mpath = virStorageBackendIsMultipath(names->name); + int is_mpath = virStorageBackendIsMultipath(names->name); if (is_mpath < 0) return -1; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 53d4d2a31a..7fc529046a 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2416,7 +2416,6 @@ virStorageBackendVolUploadLocal(virStoragePoolObjPtr pool G_GNUC_UNUSED, unsigned int flags) { char *target_path = vol->target.path; - int has_snap = 0; bool sparse = flags & VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM; g_autofree char *path = NULL; @@ -2427,7 +2426,7 @@ virStorageBackendVolUploadLocal(virStoragePoolObjPtr pool G_GNUC_UNUSED, * when volUpload is fully finished. */ if (vol->target.format == VIR_STORAGE_FILE_PLOOP) { /* Fail if the volume contains snapshots or we failed to check it.*/ - has_snap = storageBackendPloopHasSnapshots(vol->target.path); + int has_snap = storageBackendPloopHasSnapshots(vol->target.path); if (has_snap < 0) { return -1; } else if (!has_snap) { @@ -2456,13 +2455,12 @@ virStorageBackendVolDownloadLocal(virStoragePoolObjPtr pool G_GNUC_UNUSED, unsigned int flags) { char *target_path = vol->target.path; - int has_snap = 0; bool sparse = flags & VIR_STORAGE_VOL_DOWNLOAD_SPARSE_STREAM; g_autofree char *path = NULL; virCheckFlags(VIR_STORAGE_VOL_DOWNLOAD_SPARSE_STREAM, -1); if (vol->target.format == VIR_STORAGE_FILE_PLOOP) { - has_snap = storageBackendPloopHasSnapshots(vol->target.path); + int has_snap = storageBackendPloopHasSnapshots(vol->target.path); if (has_snap < 0) { return -1; } else if (!has_snap) { diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 634e9ac8cd..497b409989 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1583,7 +1583,6 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd) virStoragePoolInfo info; virStoragePoolPtr pool; int autostart = 0; - int persistent = 0; bool ret = true; bool bytes = false; char uuid[VIR_UUID_STRING_BUFLEN]; @@ -1601,6 +1600,8 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd) if (virStoragePoolGetInfo(pool, &info) == 0) { double val; const char *unit; + int persistent; + vshPrint(ctl, "%-15s %s\n", _("State:"), virshStoragePoolStateToString(info.state));