From mboxrd@z Thu Jan 1 00:00:00 1970 From: Meng Xu Subject: [PATCH] libxl: correct libxl to obey libxl's programming paramdigm Date: Wed, 30 Jul 2014 12:18:55 -0400 Message-ID: <1406737135-3106-1-git-send-email-mengxu@cis.upenn.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Meng Xu , xumengpanda@gmail.com, ian.jackson@eu.citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org When sched_domain_get() return rc != 0, scinfo will not be disposed. This violates the libxl programming paradigm: 272 * The user must always calls "dispose" exactly 273 * once afterwards, to clean up, regardless of whether operations on 274 * this object succeeded or failed. Signed-off-by: Meng Xu --- tools/libxl/xl_cmdimpl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 01bce2f..d1efdd7 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -5014,7 +5014,7 @@ static int sched_credit_domain_output(int domid) } rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo); if (rc) - return rc; + goto out; domname = libxl_domid_to_name(ctx, domid); printf("%-33s %4d %6d %4d\n", domname, @@ -5022,6 +5022,7 @@ static int sched_credit_domain_output(int domid) scinfo.weight, scinfo.cap); free(domname); +out: libxl_domain_sched_params_dispose(&scinfo); return 0; } @@ -5060,13 +5061,14 @@ static int sched_credit2_domain_output( } rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT2, domid, &scinfo); if (rc) - return rc; + goto out; domname = libxl_domid_to_name(ctx, domid); printf("%-33s %4d %6d\n", domname, domid, scinfo.weight); free(domname); +out: libxl_domain_sched_params_dispose(&scinfo); return 0; } @@ -5085,7 +5087,7 @@ static int sched_sedf_domain_output( } rc = sched_domain_get(LIBXL_SCHEDULER_SEDF, domid, &scinfo); if (rc) - return rc; + goto out; domname = libxl_domid_to_name(ctx, domid); printf("%-33s %4d %6d %6d %7d %5d %6d\n", domname, @@ -5096,6 +5098,7 @@ static int sched_sedf_domain_output( scinfo.extratime, scinfo.weight); free(domname); +out: libxl_domain_sched_params_dispose(&scinfo); return 0; } -- 1.7.9.5