xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Meng Xu <mengxu@cis.upenn.edu>
Cc: wei.liu2@citrix.com, ian.campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, ian.jackson@eu.citrix.com,
	xen-devel@lists.xen.org, xumengpanda@gmail.com
Subject: Re: [PATCH] libxl: correct libxl to obey libxl's programming paramdigm
Date: Thu, 31 Jul 2014 15:11:13 +0100	[thread overview]
Message-ID: <E1XCr4p-0007Na-H6@lists.xen.org> (raw)
In-Reply-To: <1406737135-3106-1-git-send-email-mengxu@cis.upenn.edu>

On Wed, Jul 30, 2014 at 12:18:55PM -0400, Meng Xu wrote:
> 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.
> 

I would remove the line number because the header file changes as much
sutffs added in.

> Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
> ---
>  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);

And you seem to miss this part of that paradigm:

* IDL-generated libxl types should be used as follows: the user must           
* always call the "init" function before using a type, even if the             
* variable is simply being passed by reference as an out parameter             
* to a libxl function.

So calling dispose in the end while not calling init at the beginning is
still bogus.

Wei.

  reply	other threads:[~2014-07-31 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-30 16:18 [PATCH] libxl: correct libxl to obey libxl's programming paramdigm Meng Xu
2014-07-31 14:11 ` Wei Liu [this message]
     [not found] ` <53da4e8b.12a9e00a.4198.fffffe41SMTPIN_ADDED_MISSING@mx.google.com>
2014-08-01 16:37   ` Meng Xu
2014-08-01 17:02     ` Wei Liu
2014-08-04 10:20       ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1XCr4p-0007Na-H6@lists.xen.org \
    --to=wei.liu2@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=mengxu@cis.upenn.edu \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xumengpanda@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).