[libvirt] [PATCH 01/22] qemu: Always format formatStr for blockdev-snapshot-sync

John Ferlan posted 22 patches 8 years, 10 months ago
[libvirt] [PATCH 01/22] qemu: Always format formatStr for blockdev-snapshot-sync
Posted by John Ferlan 8 years, 10 months ago
The qemuDomainSnapshotPrepare should always set a > 0 format value anyway,
so remove the check.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/qemu/qemu_driver.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0e06508..6762952 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14072,8 +14072,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
     dd->prepared = true;
 
     /* create the actual snapshot */
-    if (dd->src->format)
-        formatStr = virStorageFileFormatTypeToString(dd->src->format);
+    formatStr = virStorageFileFormatTypeToString(dd->src->format);
 
     /* The monitor is only accessed if qemu doesn't support transactions.
      * Otherwise the following monitor command only constructs the command.
-- 
2.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 01/22] qemu: Always format formatStr for blockdev-snapshot-sync
Posted by Peter Krempa 8 years, 10 months ago
On Wed, Mar 22, 2017 at 10:21:14 -0400, John Ferlan wrote:
> The qemuDomainSnapshotPrepare should always set a > 0 format value anyway,
> so remove the check.
> 
> Found by Coverity.
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
>  src/qemu/qemu_driver.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 0e06508..6762952 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -14072,8 +14072,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
>      dd->prepared = true;
>  
>      /* create the actual snapshot */
> -    if (dd->src->format)
> -        formatStr = virStorageFileFormatTypeToString(dd->src->format);
> +    formatStr = virStorageFileFormatTypeToString(dd->src->format);

dd->src->format will be always non-zero so formatStr is guaranteed not
to return NULL. The value is assigned in qemuDomainSnapshotPrepare

The condition is probably useless here.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list