[libvirt] [PATCH 1/2] qemu: Refactor qemuParseCommandLine error path for vnc parse

Ján Tomko jtomko at redhat.com
Tue Feb 9 15:35:53 UTC 2016


On Tue, Feb 09, 2016 at 07:34:01AM -0500, John Ferlan wrote:
> Rather than have vnc be a variable within the if, promote it
> to the top, then adjust the code to use the error label to call
> virDomainGraphicsDefFree
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/qemu/qemu_command.c | 24 ++++++------------------
>  1 file changed, 6 insertions(+), 18 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index d7f19f3..7b5a36f 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -12999,6 +12999,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
>      int nvirtiodisk = 0;
>      qemuDomainCmdlineDefPtr cmd = NULL;
>      virDomainDiskDefPtr disk = NULL;
> +    virDomainGraphicsDefPtr vnc = NULL;
>      const char *ceph_args = qemuFindEnv(progenv, "CEPH_ARGS");
>      bool have_sdl = false;
>  

[...]

> @@ -13991,6 +13978,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
>      return def;
>  
>   error:
> +    virDomainGraphicsDefFree(vnc);
>      virDomainDiskDefFree(disk);
>      qemuDomainCmdlineDefFree(cmd);
>      virDomainDefFree(def);

The Free call is almost a thousand lines after the declaration.
This is a great opportunity to split out the VNC parsing into
a separate function, especially since it seems that its only input
is a const char* pointing to the command line option and the only
output is one virDomainGraphicsDef structure.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160209/26e424db/attachment-0001.sig>


More information about the libvir-list mailing list