Make variables more local. Put failure case for !blk first to avoid an additional else block with indentation.
Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- Can be squashed into "PVE-Backup: Proxmox backup patches for QEMU". pve-backup.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/pve-backup.c b/pve-backup.c index 75af865437..4b0dcca246 100644 --- a/pve-backup.c +++ b/pve-backup.c @@ -585,8 +585,6 @@ static GList coroutine_fn *get_device_info( const char *devlist, Error **errp) { - BlockBackend *blk; - BlockDriverState *bs = NULL; gchar **devs = NULL; GList *di_list = NULL; @@ -595,29 +593,26 @@ static GList coroutine_fn *get_device_info( gchar **d = devs; while (d && *d) { - blk = blk_by_name(*d); - if (blk) { - bs = blk_bs(blk); - if (!bdrv_co_is_inserted(bs)) { - error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d); - goto err; - } - PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1); - di->bs = bs; - di_list = g_list_append(di_list, di); - } else { + BlockBackend *blk = blk_by_name(*d); + if (!blk) { error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", *d); goto err; } + BlockDriverState *bs = blk_bs(blk); + if (!bdrv_co_is_inserted(bs)) { + error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d); + goto err; + } + PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1); + di->bs = bs; + di_list = g_list_append(di_list, di); d++; } - } else { BdrvNextIterator it; - bs = NULL; - for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { + for (BlockDriverState *bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { if (!bdrv_co_is_inserted(bs) || bdrv_is_read_only(bs)) { continue; } -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel