[PATCH 12/36] conf: convert virDomainChrSourceDef to GObject
Jonathon Jongsma
jjongsma at redhat.com
Wed Apr 8 20:28:25 UTC 2020
On Fri, 2020-04-03 at 17:15 +0200, Rafael Fonseca wrote:
> Signed-off-by: Rafael Fonseca <r4f4rfs at gmail.com>
> ---
> src/conf/domain_conf.c | 35 ++++++++++++++++-------------------
> src/conf/domain_conf.h | 9 ++++++++-
> src/qemu/qemu_domain.c | 7 ++++---
> src/qemu/qemu_process.c | 3 +--
> src/qemu/qemu_virtiofs.c | 12 +++++-------
> 5 files changed, 34 insertions(+), 32 deletions(-)
>
>
[snip]
> -VIR_ONCE_GLOBAL_INIT(virDomainChrSourceDef);
> -
> virDomainChrSourceDefPtr
> virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt)
> {
> virDomainChrSourceDefPtr def = NULL;
In analogous *New() functions in previous patches you've used the
g_autoptr/g_steal_pointer approach. Consider using it here as well.
>
> - if (virDomainChrSourceDefInitialize() < 0)
> - return NULL;
> -
> - if (!(def = virObjectNew(virDomainChrSourceDefClass)))
> - return NULL;
> + def =
> VIR_DOMAIN_CHR_SOURCE_DEF(g_object_new(VIR_TYPE_DOMAIN_CHR_SOURCE_DEF
> , NULL));
>
> if (xmlopt && xmlopt->privateData.chrSourceNew &&
> !(def->privateData = xmlopt->privateData.chrSourceNew())) {
> - virObjectUnref(def);
> - def = NULL;
> + g_clear_object(&def);
Then you could just directly return NULL here.
> }
>
> return def;
>
Jonathon
More information about the libvir-list
mailing list