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

Erik Skultety eskultet at redhat.com
Thu Sep 26 09:23:11 UTC 2019


On Wed, Sep 18, 2019 at 11:56:58AM -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 the last part of this change.
>
> Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
> ---
...

>
> @@ -22506,7 +22479,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
>          if (virFileIsLink(old_dom_autostart_link) &&
>              unlink(old_dom_autostart_link) < 0) {
>              virReportSystemError(errno,
> -                                 _("Failed to delete symlink '%s'"),
> +                                _("Failed to delete symlink '%s'"),

^Undesirable hunk

Same as with VIR_AUTOUNREF, this focuses on strings only, I'd extend this also
for other primitive scalar pointers:

cpuwait in qemuDomainGetStatsVcpu
flags in qemuStateStop

There are other occasions at which we use VIR_FREE and could be replaced, but
those are not scalar type pointers and I the policy I believe we settled with
is not to use VIR_AUTOFREE with compound types, instead a dedicated VIR_AUTOPTR
should be created.

Erik




More information about the libvir-list mailing list