Jeff Squyres wrote:
> On Dec 16, 2009, at 3:35 PM, Jeff Squyres wrote:
>
>   
>> While preparing to SVN commit, I made the default for HG checkouts to 
>> compile with debug and picky modes.  I now see a TRUCKLOAD of 
>> signed/unsigned comparison warnings.  I'll look into these right now...
>>     
>
> A bunch of them were fairly straightforward "using int and unsigned together" 
> cases that were easy to fix.  But some of them are less clear -- comparing 
> what should be unsigned values with -1.  This makes me believe that -1 is 
> being used as a sentinel value in some places -- e.g., in 
> hwloc_obj_t->os_index.  It's a "signed" field, but many of the comparisons 
> that are made to it are from "unsigned" variables.  And at least in one or 
> two places, it is compared against -1.
>   

os_index == -1 means that it is unknown (or does not mean anything or
whatever).

> Which should be fixed -- make the .os_index field be unsigned (and either 
> have another boolean indicating whether the .os_index value is valid or not, 
> or having a sentinel value for invalid (perhaps ((unsigned) -1)?), or make 
> all the comparison variables be unsigned?
>   

(unsigned) -1 is fine with me.

Brice

Reply via email to