|
From: | Bill Auerbach |
Subject: | RE: [lwip-devel] Port on 16 bits processor: problem in ip4_addr_netmask_valid() function |
Date: | Fri, 18 Feb 2011 08:41:18 -0500 |
Yes, the U is needed. ANSI C defaults to type signed int for
Hex constants unless the constant won’t fit in a signed int. Chances are in C if
you use 0x you intended an unsigned value and the U needs to be explicitly added
in those cases. Bill In
def.h:
#define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00)
>> 8)) In
ip.h:
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
#define IP_MF 0x2000 /* more
fragments flag */ I
think IP_OFFMASK and IP_MF (and others) should be declared unsigned ('U'
suffix), otherwise the left shifting by 8 positions can could wrong for a
signed int. What
do you think? |
[Prev in Thread] | Current Thread | [Next in Thread] |