[libvirt] [PATCH 0/2] virsh: perf: Trivial fixes of a memleak and coding style

Both are pushed under the trivial rule. Peter Krempa (2): virsh: perf: Don't leak domain virsh: perf: Remove unnecessary 'error' label tools/virsh-domain.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.8.1

After failing to parse the perf event list, the code would return failure without freeing the previously acquired object. Rearrange the code to avoid the problem. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329046 --- tools/virsh-domain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a1d4a75..4a73a80 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8623,13 +8623,13 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) if (live) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) - return false; - if (vshCommandOptStringReq(ctl, cmd, "enable", &enable) < 0 || vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0) return false; + if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) + return false; + if (enable && virshParseEventStr(enable, true, ¶ms, &nparams, &maxparams) < 0) goto cleanup; -- 2.8.1

The only place that uses it doesn't warrant a separate label. --- tools/virsh-domain.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 4a73a80..a9f70dc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8652,8 +8652,10 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) } } } else { - if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) - goto error; + if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) { + vshError(ctl, "%s", _("Unable to enable/disable perf events")); + goto cleanup; + } } ret = true; @@ -8661,10 +8663,6 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) virTypedParamsFree(params, nparams); virDomainFree(dom); return ret; - - error: - vshError(ctl, "%s", _("Unable to enable/disable perf events")); - goto cleanup; } -- 2.8.1

On 04/21/2016 03:56 AM, Peter Krempa wrote:
Both are pushed under the trivial rule.
Peter Krempa (2): virsh: perf: Don't leak domain virsh: perf: Remove unnecessary 'error' label
tools/virsh-domain.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
ACK series - Cole
participants (2)
-
Cole Robinson
-
Peter Krempa