[PATCH] qemu: Avoid useless tmp variable in qemuCanonicalizeMachine

Jiri Denemark posted 1 patch 3 weeks ago
src/qemu/qemu_postparse.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] qemu: Avoid useless tmp variable in qemuCanonicalizeMachine
Posted by Jiri Denemark 3 weeks ago
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_postparse.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/qemu/qemu_postparse.c b/src/qemu/qemu_postparse.c
index 11134fb030..03b5ef825a 100644
--- a/src/qemu/qemu_postparse.c
+++ b/src/qemu/qemu_postparse.c
@@ -947,10 +947,8 @@ qemuCanonicalizeMachine(virDomainDef *def, virQEMUCaps *qemuCaps)
         return 0;
 
     if (STRNEQ(canon, def->os.machine)) {
-        char *tmp;
-        tmp = g_strdup(canon);
         VIR_FREE(def->os.machine);
-        def->os.machine = tmp;
+        def->os.machine = g_strdup(canon);
     }
 
     return 0;
-- 
2.47.0
Re: [PATCH] qemu: Avoid useless tmp variable in qemuCanonicalizeMachine
Posted by Daniel P. Berrangé 3 weeks ago
On Fri, Nov 15, 2024 at 12:45:28PM +0100, Jiri Denemark wrote:
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_postparse.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_postparse.c b/src/qemu/qemu_postparse.c
> index 11134fb030..03b5ef825a 100644
> --- a/src/qemu/qemu_postparse.c
> +++ b/src/qemu/qemu_postparse.c
> @@ -947,10 +947,8 @@ qemuCanonicalizeMachine(virDomainDef *def, virQEMUCaps *qemuCaps)
>          return 0;
>  
>      if (STRNEQ(canon, def->os.machine)) {
> -        char *tmp;
> -        tmp = g_strdup(canon);
>          VIR_FREE(def->os.machine);
> -        def->os.machine = tmp;
> +        def->os.machine = g_strdup(canon);
>      }

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|