[libvirt] [PATCH 4/6] qemu_driver: use VIR_AUTOFREE() with strings 1/3

Erik Skultety eskultet at redhat.com
Thu Sep 26 09:19:00 UTC 2019


On Wed, Sep 18, 2019 at 11:56:56AM -0300, Daniel Henrique Barboza wrote:
> VIR_AUTOFREE is a beautiful macro. Let's use it across the board
> inside qemu_driver.c to make the code a bit tidier and smaller,
> sparing VIR_FREE() calls and sometimes a whole 'cleanup'
> label.
>
> This is a huge change due to the amount of char * declared in
> this file, thus let's split it in 3. This is the first part.
>
> Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
> ---
...

> @@ -3000,7 +2978,7 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
>      size_t cookie_len = 0;
>      int ret = -1;
>      size_t zerosLen = 0;
> -    char *zeros = NULL;
> +    VIR_AUTOFREE(char *) zeros = NULL;
>
>      xml_len = strlen(data->xml) + 1;
>      if (data->cookie)
> @@ -3057,7 +3035,6 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
>      ret = 0;
>
>   cleanup:

^This cleanup can be dropped.

Erik




More information about the libvir-list mailing list