[ofw] RE: [OPENSM] cast to remove warnings about signed vs. unsigned comparisons

Smith, Stan stan.smith at intel.com
Thu Oct 1 10:41:37 PDT 2009


Jason Gunthorpe wrote:
> On Thu, Oct 01, 2009 at 09:14:50AM -0700, Smith, Stan wrote:
>
>> Upcoming patches do contain a fair amount of casting for those
>> assignment cases where IB defined fields uint8_t/uint16_t are
>> assiged from larger sized variable. Will examine code in further
>> detail favoring var declaration changes for signed/unsigned
>> comparisions.  W.r.t. opensm/* files, the end is in sight. There are
>> 18 more patch files coming, will reinspect for less casting.
>
> I've always felt the warning on implicit cast from larger to smaller
> type to be somewhat useless - that is an unavoidable operation when
> working with networking. Adding casts does nothing to actually improve
> the code, and trying to change to smaller types results in worse code
> gen and no improvement in function.
>
> Maybe OFW would be better off just turning that warning off? :)

Perhaps I'm old-school, in that I'd rather see all the details/warnings which forces a closer examination of the situation.
Over the years I've discovered that ignoring information leads to long debug sessions...

The thing about casting is you can read the code and see what's going on 'in context' without having to look someplace else (.h file) or perhaps make erroneous asumptions.

That said, dealing with overzealous hand-holding compilers is never pleasant.
Will consider suppression of warning information.

>
>>> In general to simplify a detection of such cases we can consider to
>>> use -Wsign-compare gcc flag in linux environment.
>
> And -Wsign-conversion
>
> Jason




More information about the ofw mailing list