[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 6/6] xen/build: Use the system stdbool.h header



On 22/06/16 13:43, Jan Beulich wrote:
>>>> On 22.06.16 at 13:24, <andrew.cooper3@xxxxxxxxxx> wrote:
>> --- a/xen/arch/x86/acpi/cpu_idle.c
>> +++ b/xen/arch/x86/acpi/cpu_idle.c
>> @@ -480,7 +480,7 @@ void trace_exit_reason(u32 *irq_traced)
>>   */
>>  bool_t errata_c6_eoi_workaround(void)
>>  {
>> -    static bool_t fix_needed = -1;
>> +    static int fix_needed = -1;
> int8_t then please.
>
>> --- a/xen/arch/x86/genapic/probe.c
>> +++ b/xen/arch/x86/genapic/probe.c
>> @@ -56,7 +56,8 @@ custom_param("apic", genapic_apic_force);
>>  
>>  void __init generic_apic_probe(void) 
>>  { 
>> -    int i, changed;
>> +    bool_t changed;
>> +    int i;
> You mention it in the description, but I can't see what's wrong with
> the current code (and hence I can't conclude what complaint the
> compiler has to make).

This one was indeed odd.

probe.c:64:2: error: suggest parentheses around assignment used as truth
value [-Werror=parentheses]
  cmdline_apic = changed = (genapic != NULL);
  ^

This is with

andrewcoop@andrewcoop:/local/xen.git/xen$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2
...

Modifying the line to

cmdline_apic = (changed = (genapic != NULL));

also resolves the warning, so I suspect it is complaining about the
implicit truncation of bool = int = rvalue, without taking into account
that the rvalue is strictly 0 or 1.


>
> Also now that you introduce plain bool - why do you use bool_t
> here?

If we want to go in that direction, then certainly.  I was going to pose
the question bool_t/bool question later, but it would be my preference
to make a transition towards bool.

>
>> @@ -46,4 +47,8 @@ typedef __u32 __be32;
>>  typedef __u64 __le64;
>>  typedef __u64 __be64;
>>  
>> +typedef _Bool bool_t;
>> +#define test_and_set_bool(b)   xchg(&(b), 1)
>> +#define test_and_clear_bool(b) xchg(&(b), 0)
> I guess you then want to use true and false here (which we should
> gradually switch to along with the bool_t -> bool transition)?

I was hoping to find a better place for those to live, as types.h isn't
appropriate.  Still, the global types.h is better than having identical
copies in arch specific types.h

~Andrew

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.