All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Joshua Otto <jtotto@uwaterloo.ca>,
	xen-devel@lists.xen.org, Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com,
	george.dunlap@eu.citrix.com, dario.faggioli@citrix.com,
	ian.jackson@eu.citrix.com, czylin@uwaterloo.ca,
	hjarmstr@uwaterloo.ca
Subject: Re: [PATCH 1/5] libxl: tidy libxl_get_scheduler() according to CODING_STYLE
Date: Mon, 4 Jan 2016 16:23:47 +0000	[thread overview]
Message-ID: <1451924627.13361.178.camel@citrix.com> (raw)
In-Reply-To: <1451279808-25264-2-git-send-email-jtotto@uwaterloo.ca>

On Mon, 2015-12-28 at 00:16 -0500, Joshua Otto wrote:
> To more closely follow the guidelines in CODING_STYLE, store the result
> of the libxc call in the local variable r, and the check the result of
> the call in a separate statement.

I think a far more important aspect of this change is: 
    don't store the int return value of xc_sched_id into a variable of type
    libxl_scheduler

libxl_scheduler is an enum, and hence "int-like", but... still.

I think this is worth mentioning in the commit message, mainly because I'm
only 99% confident this is just a benign oddity rather than an actual
latent bug.

> Additionally, change the error log statement to more accurately reflect
> the failure.  This is the only functional change introduced by this
> patch.

Right.

> Signed-off-by: Joshua Otto <jtotto@uwaterloo.ca>


> ---
>  tools/libxl/libxl.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 9207621..ca4679b 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -5585,10 +5585,11 @@ out:
>  
>  libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
>  {
> -    libxl_scheduler sched, ret;
>      GC_INIT(ctx);
> -    if ((ret = xc_sched_id(ctx->xch, (int *)&sched)) != 0) {
> -        LOGE(ERROR, "getting domain info list");
> +    libxl_scheduler sched;
> +    int r = xc_sched_id(ctx->xch, (int *)&sched);

If you were minded to make a further cleanup (i.e. this is totally
optional) then I'm not convinced this case is actually safe, since
libxl_scheduler could potentially be smaller than sizeof(int), or at least
IIRC the C standard give the compiler that option, although I don't know if
gcc will make use of it or if something else (e.g. OS calling convention on
Linux) would make it a non-issue (or I might be totally wrong...).

Safer (and cleaner looking even if I'm wrong) would be to use a temporary
int for the function call and turn it into an enum implicitly in the
return.

> +    if (r != 0) {
> +        LOGE(ERROR, "getting current scheduler id");
>          return ERROR_FAIL;
>          GC_FREE;
>      }

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-01-04 16:23 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 20:26 Taking on a Xen development project jtotto
2015-12-10 10:59 ` Wei Liu
2015-12-10 17:23 ` Andrew Cooper
2015-12-12  2:19   ` Yang Hongyang
2015-12-12 22:30     ` Joshua Otto
2015-12-12 23:02       ` Andrew Cooper
2015-12-14 22:49         ` Joshua Otto
2015-12-11 13:52 ` Ian Campbell
2015-12-12 22:07   ` Joshua Otto
2015-12-14 11:08     ` Ian Campbell
2015-12-14 22:59       ` Joshua Otto
2015-12-15 15:48         ` Ian Campbell
2015-12-28  5:16       ` Coverity tidying Joshua Otto
2015-12-28  5:16         ` [PATCH 1/5] libxl: tidy libxl_get_scheduler() according to CODING_STYLE Joshua Otto
2016-01-04 16:23           ` Ian Campbell [this message]
2016-01-05  8:20             ` Dario Faggioli
2016-01-19  5:57               ` [PATCH v2 " Chester Lin
2016-01-19  9:14                 ` Dario Faggioli
2016-01-19 11:28                 ` Wei Liu
2016-01-19 11:35                   ` Ian Campbell
2015-12-28  5:16         ` [PATCH 2/5] libxl: make GC_FREE reachable in libxl_get_scheduler() Joshua Otto
2016-01-04 16:29           ` Ian Campbell
2016-01-05  8:49             ` Dario Faggioli
2016-01-05 11:16               ` Ian Campbell
2016-01-19  5:57                 ` [PATCH v2 " Chester Lin
2016-01-19  9:08                   ` Dario Faggioli
2016-01-19 14:15                   ` Ian Jackson
2015-12-28  5:16         ` [PATCH 3/5] ns16550: widen an integer constant for Coverity Joshua Otto
2016-01-04 16:36           ` Ian Campbell
2016-01-06  9:26             ` Jan Beulich
2016-01-19  5:57               ` [PATCH v2 3/5] n16550: add sanity check for reg_shift Chester Lin
2016-01-19 13:32                 ` Jan Beulich
2016-01-25  0:41                   ` czylin
2015-12-28  5:16         ` [PATCH 4/5] credit: remove pointless local variable initialization Joshua Otto
2015-12-28  5:16         ` [PATCH 5/5] libxl: Add explicit cast to libxl_psr_cat_set_cbm Joshua Otto
2016-01-04 16:40           ` Ian Campbell
2016-01-19  5:58             ` [PATCH v2 " Chester Lin
2016-01-19  8:34               ` Dario Faggioli
2016-01-19 14:06               ` Ian Jackson
2016-01-19 14:21                 ` Ian Campbell
2016-01-19 14:28                   ` Dario Faggioli
2016-01-19 14:33                     ` Ian Jackson
2016-01-19 14:31                   ` George Dunlap
2016-01-19 14:31                 ` Ian Campbell
2016-01-19 14:35                   ` Ian Jackson
2017-01-12 18:08                     ` George Dunlap
2017-01-13  9:05                       ` Dario Faggioli
2015-12-28  9:34         ` Coverity tidying Andrew Cooper
2016-01-01  3:14           ` [PATCH] svm: rephrase local variable use for Coverity Joshua Otto
2016-01-06 13:24             ` Jan Beulich
2016-01-06 14:33               ` Boris Ostrovsky

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=1451924627.13361.178.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=czylin@uwaterloo.ca \
    --cc=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=hjarmstr@uwaterloo.ca \
    --cc=jtotto@uwaterloo.ca \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.