All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com,
	stefano.stabellini@citrix.com
Subject: Re: [PATCH v2] tools/libxl: libxl_get_scheduler should return an int
Date: Fri, 21 Mar 2014 14:50:24 +0000	[thread overview]
Message-ID: <532C51B0.6040202@linaro.org> (raw)
In-Reply-To: <1395405831.19839.34.camel@kazak.uk.xensource.com>

On 03/21/2014 12:43 PM, Ian Campbell wrote:
> On Fri, 2014-03-21 at 12:25 +0000, Julien Grall wrote:
>> libxl_get_scheduler returns either a valid value in enum range or ERROR_FAIL.
>>
>> As function return type is an enum, chekcing if the value is negative will
> 
> "checking"

I will update the commit message.

>> be always false. Therefore both GCC and clang will never go to the error
>> case.
> 
> Are there any API compatibility concerns here? I think there isn't
> because
> 	enum foo bar = get_foo()
> and
> 	int bar = get_foo()
> are both always valid whether get_foo() returns an enum foo or an int.
> 
> So I think we can make this change without a LIBXL_HAVE define. Would be
> good to confirm and include the rationale in the commit log.

C99, 6.7.2.2p4

Each enumerated type shall be compatible with char, a signed integer
type, or an unsigned integer type. The choice of type is
implementation-defined,108) but shall be capable of representing the
values of all the members of the enumeration. [...]

I gave a try with a simple test file:
typedef enum libxl_sched
{
  SCHED_SCHED,
} libxl_sched;

int f(void);

int main(void)
{
    libxl_sched sched = f();

    return 0;
}

I compiled twice, the second time I have changed f return type.

The result is the same with gcc 4.7 on x86. For ARM with gcc 4.6.3 there
is an extra move on the first version. IHMO it's not harmfull.

Regards

-- 
Julien Grall

  parent reply	other threads:[~2014-03-21 14:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-21 12:25 [PATCH v2] tools/libxl: libxl_get_scheduler should return an int Julien Grall
2014-03-21 12:43 ` Ian Campbell
2014-03-21 14:31   ` Ian Jackson
2014-03-21 14:50   ` Julien Grall [this message]
2014-03-21 15:06     ` Ian Jackson
2014-03-21 14:28 ` Ian Jackson
2014-03-21 14:40   ` Julien Grall
2014-03-21 15:02     ` Ian Jackson
2014-03-21 15:14       ` Julien Grall
2014-03-21 15:21         ` Ian Jackson
2014-03-21 15:25           ` Julien Grall
2014-03-21 16:11   ` 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=532C51B0.6040202@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=xen-devel@lists.xenproject.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.