[libvirt] [PATCH 6/9] qemu: command: use VIR_AUTOFREE in qemuBuildFSDevCommandLine

Ján Tomko posted 9 patches 6 years, 6 months ago
[libvirt] [PATCH 6/9] qemu: command: use VIR_AUTOFREE in qemuBuildFSDevCommandLine
Posted by Ján Tomko 6 years, 6 months ago
Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_command.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 02a6642207..8617b010dc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2807,7 +2807,7 @@ qemuBuildFSDevCommandLine(virCommandPtr cmd,
                           const virDomainDef *def,
                           virQEMUCapsPtr qemuCaps)
 {
-    char *optstr;
+    VIR_AUTOFREE(char *) optstr = NULL;
 
     virCommandAddArg(cmd, "-fsdev");
     if (!(optstr = qemuBuildFSStr(fs)))
@@ -2822,7 +2822,6 @@ qemuBuildFSDevCommandLine(virCommandPtr cmd,
     if (!(optstr = qemuBuildFSDevStr(def, fs, qemuCaps)))
         return -1;
     virCommandAddArg(cmd, optstr);
-    VIR_FREE(optstr);
 
     return 0;
 }
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/9] qemu: command: use VIR_AUTOFREE in qemuBuildFSDevCommandLine
Posted by Peter Krempa 6 years, 6 months ago
On Tue, Jul 16, 2019 at 13:06:54 +0200, Ján Tomko wrote:
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/qemu_command.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 02a6642207..8617b010dc 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -2807,7 +2807,7 @@ qemuBuildFSDevCommandLine(virCommandPtr cmd,
>                            const virDomainDef *def,
>                            virQEMUCapsPtr qemuCaps)
>  {
> -    char *optstr;
> +    VIR_AUTOFREE(char *) optstr = NULL;

'optstr' is used twice in this function. If you want to convert to
VIR_AUTOFREE, introduce two variables for the two distinct uses.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list