src/qemu/qemu_block.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
Just Return when alias is null and Remove the 'ret' variable.
Signed-off-by: Yi Li <yili@winhong.com>
---
src/qemu/qemu_block.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 0b8ca2a3f5..32b6500a3d 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -280,25 +280,22 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk,
qemuBlockNodeNameBackingChainDataPtr entry = NULL;
virStorageSourcePtr src = disk->src;
g_autofree char *alias = NULL;
- int ret = -1;
/* don't attempt the detection if the top level already has node names */
if (src->nodeformat || src->nodestorage)
return 0;
if (!(alias = qemuAliasDiskDriveFromDisk(disk)))
- goto cleanup;
+ return 0;
- if (!(entry = virHashLookup(disktable, alias))) {
- ret = 0;
- goto cleanup;
- }
+ if (!(entry = virHashLookup(disktable, alias)))
+ return 0;
while (virStorageSourceIsBacking(src) && entry) {
if (src->nodeformat || src->nodestorage) {
if (STRNEQ_NULLABLE(src->nodeformat, entry->nodeformat) ||
STRNEQ_NULLABLE(src->nodestorage, entry->nodestorage))
- goto cleanup;
+ goto error;
break;
} else {
@@ -310,13 +307,11 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk,
src = src->backingStore;
}
- ret = 0;
-
- cleanup:
- if (ret < 0)
- qemuBlockDiskClearDetectedNodes(disk);
+ return 0;
- return ret;
+ error:
+ qemuBlockDiskClearDetectedNodes(disk);
+ return -1;
}
--
2.25.3
On a Thursday in 2021, Yi Li wrote:
>Just Return when alias is null and Remove the 'ret' variable.
>
>Signed-off-by: Yi Li <yili@winhong.com>
>---
> src/qemu/qemu_block.c | 21 ++++++++-------------
> 1 file changed, 8 insertions(+), 13 deletions(-)
>
>diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
>index 0b8ca2a3f5..32b6500a3d 100644
>--- a/src/qemu/qemu_block.c
>+++ b/src/qemu/qemu_block.c
>@@ -280,25 +280,22 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk,
> qemuBlockNodeNameBackingChainDataPtr entry = NULL;
> virStorageSourcePtr src = disk->src;
> g_autofree char *alias = NULL;
>- int ret = -1;
>
> /* don't attempt the detection if the top level already has node names */
> if (src->nodeformat || src->nodestorage)
> return 0;
>
> if (!(alias = qemuAliasDiskDriveFromDisk(disk)))
>- goto cleanup;
>+ return 0;
Before, 'ret' was set to -1 and jumping to cleanup skipped over the
other assignment. This should be return -1
Jano
>
>- if (!(entry = virHashLookup(disktable, alias))) {
>- ret = 0;
>- goto cleanup;
>- }
>+ if (!(entry = virHashLookup(disktable, alias)))
>+ return 0;
>
Just return when alias is null and Remove the 'ret' variable.
Signed-off-by: Yi Li <yili@winhong.com>
---
src/qemu/qemu_block.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 3d88e701b2..0af3e56c9a 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -280,25 +280,22 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk,
qemuBlockNodeNameBackingChainDataPtr entry = NULL;
virStorageSourcePtr src = disk->src;
g_autofree char *alias = NULL;
- int ret = -1;
/* don't attempt the detection if the top level already has node names */
if (src->nodeformat || src->nodestorage)
return 0;
if (!(alias = qemuAliasDiskDriveFromDisk(disk)))
- goto cleanup;
+ return -1;
- if (!(entry = virHashLookup(disktable, alias))) {
- ret = 0;
- goto cleanup;
- }
+ if (!(entry = virHashLookup(disktable, alias)))
+ return 0;
while (virStorageSourceIsBacking(src) && entry) {
if (src->nodeformat || src->nodestorage) {
if (STRNEQ_NULLABLE(src->nodeformat, entry->nodeformat) ||
STRNEQ_NULLABLE(src->nodestorage, entry->nodestorage))
- goto cleanup;
+ goto error;
break;
} else {
@@ -310,13 +307,11 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk,
src = src->backingStore;
}
- ret = 0;
-
- cleanup:
- if (ret < 0)
- qemuBlockDiskClearDetectedNodes(disk);
+ return 0;
- return ret;
+ error:
+ qemuBlockDiskClearDetectedNodes(disk);
+ return -1;
}
--
2.25.3
On a Thursday in 2021, Yi Li wrote: >Just return when alias is null and Remove the 'ret' variable. > >Signed-off-by: Yi Li <yili@winhong.com> >--- > src/qemu/qemu_block.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
© 2016 - 2026 Red Hat, Inc.