[ofw] Re: [OPENSM] cast to remove warnings about signed vs. unsigned comparisons
Sasha Khapyorsky
sashak at voltaire.com
Thu Oct 1 10:02:12 PDT 2009
On 10:27 Thu 01 Oct , Jason Gunthorpe wrote:
>
> 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.
In general I would agree, but in case of OpenSM we are not in so
excellent state where fixed size int types are always used for a reason.
For instance a code like:
int32_t i;
for (i = 0; i < SOME_CONST; i++)
do_something(array[i]);
is not so uncommon.
I would prefer to use generic int types where is possible and fixed
sized where is needed. And then yes - to ignore "int casting" warning
seems fine for me.
This could be true, but not always in our case - OpenSM code base has a
lot of fixed sized types unmotivated case where
> Maybe OFW would be better off just turning that warning off? :)
To minimize a porting efforts it could be an option.
> > > In general to simplify a detection of such cases we can consider to
> > > use -Wsign-compare gcc flag in linux environment.
>
> And -Wsign-conversion
Yes.
Sasha
More information about the ofw
mailing list