Don't rely on error check and assign hostname only when non-NULL. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 641a90d595..241513705d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22909,14 +22909,14 @@ qemuDomainGetGuestInfo(virDomainPtr dom, } if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) { rc = qemuAgentGetHostname(agent, &hostname); - if (rc < 0 && !(rc == -2 && types == 0)) { + if (rc < 0 && !(rc == -2 && types == 0)) goto exitagent; - } else { - if (virTypedParamsAddString(params, nparams, &maxparams, "hostname", - hostname) < 0) - goto exitagent; - } } + + if (hostname && + virTypedParamsAddString(params, nparams, &maxparams, "hostname", hostname) < 0) + goto exitagent; + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) { rc = qemuAgentGetFSInfo(agent, &agentfsinfo); if (rc < 0) { -- 2.24.1