NetBSD-Bugs archive

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

Re: toolchain/53618: bogus warnings from printf %u and ntohs with -O1



martin%duskware.de@localhost said:
>  This is how it traditionally worked. It does not even depend on
>  optimization level, on big endian CPUs all ntoh* are no-ops. 

Thanks, but I don't understand what you are trying to tell me.

I'm running on X86 so the no-op case shouldn't be happening.  Even if it did 
happen, the argument to ntohs is an unsigned so it shouldn't complain.

There are 4 printfs.  The first is there to make sure that I've got the 
command line switches set to generate this type of warning.  The second is 
there because I was curious.

The last 2 are the interesting ones.  There are no complaints without -O1, but 
warnings with -O1.

If I actually run the code, both produce the same output and it is what I 
expect.
Yyy 13
Y13 13
Foo 3328
Bar 3328

3328 == 0xD00


coypu%sdf.org@localhost said:
>  this is because the definition of ntohs is
>  #define ntohs(x) (x)
>  in sys/endian.h. 

That's the BYTE_ORDER == BIG_ENDIAN case
I'm running on X86 which is LITTLE_ENDIAN

#define ntohs(x)        bswap16(__CAST(uint16_t, (x)))


-- 
These are my opinions.  I hate spam.





Home | Main Index | Thread Index | Old Index