[libvirt] [PATCH 0/2] A couple of openvz fixups

Patch 1 came from "the next part" of the code when I determined that the Unref was unnecessary Patch 2 is a result of Jim Fehlig's review that openvzDomainGetHostname doesn't really need the error/cleanup logic. John Ferlan (2): openvz: Remove unnecessary Unref in openvzLoadDomains openvz: Clean up openvzDomainGetHostname src/openvz/openvz_conf.c | 1 - src/openvz/openvz_driver.c | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) -- 2.13.6

Since there is no way to get to cleanup without dom being NULL, this is a unnecessary Unref. Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/openvz/openvz_conf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 23a02d749e..a25eaf570e 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -626,7 +626,6 @@ int openvzLoadDomains(struct openvz_driver *driver) virCommandFree(cmd); VIR_FREE(temp); VIR_FREE(outbuf); - virObjectUnref(dom); virDomainDefFree(def); return -1; } -- 2.13.6

On Wed, Apr 11, 2018 at 12:57:07PM -0400, John Ferlan wrote:
Since there is no way to get to cleanup without dom being NULL, this is a unnecessary Unref.
Actually, if we could get there it would be a bug, because virDomainObjListAdd does not give us an extra reference, it just leaves the domain locked.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/openvz/openvz_conf.c | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Remove the unnecessary goto error followed by goto cleanup processing. Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/openvz/openvz_driver.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index ec9541840a..2c62dd6f29 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -319,22 +319,18 @@ openvzDomainGetHostname(virDomainPtr dom, unsigned int flags) hostname = openvzVEGetStringParam(dom, "hostname"); if (hostname == NULL) - goto error; + goto cleanup; /* vzlist prints an unset hostname as '-' */ if (STREQ(hostname, "-")) { virReportError(VIR_ERR_OPERATION_FAILED, _("Hostname of '%s' is unset"), vm->def->name); - goto error; + VIR_FREE(hostname); } cleanup: virDomainObjEndAPI(&vm); return hostname; - - error: - VIR_FREE(hostname); - goto cleanup; } -- 2.13.6

On Wed, Apr 11, 2018 at 12:57:08PM -0400, John Ferlan wrote:
Remove the unnecessary goto error followed by goto cleanup processing.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/openvz/openvz_driver.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
John Ferlan
-
Ján Tomko