[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-devel] Port on 16 bits processor: problem in ip4_addr_netmask_
From: |
Giuseppe Modugno |
Subject: |
Re: [lwip-devel] Port on 16 bits processor: problem in ip4_addr_netmask_valid() function |
Date: |
Fri, 18 Feb 2011 09:40:47 +0100 |
On 17 Feb 2011 at 13:58, Simon Goldschmidt wrote:
> "Giuseppe Modugno" <address@hidden> wrote:
> > [...]
> > The operation 1U << 31 can't be well performed on a 16 bits
> > processor. It should be (u32_t)1U << 31. What do you think?
>
> I guess it should rather be '1UL' instead of '(u32_t)1U' (which should also work...). Does 1UL yield to a 32-bit constant for your controller?
Yes, you're right. It's better '1UL'.
> BTW: This should be fixed for the 1.4.0 release, since it's really a small fix.
>
> Also, please let us know if you run into any other problems regarding the 16-bit processor, as there haven't been many people active on the lists using 16-bit processors lately.
I have found another issue in ip_addr.c. Consider the following
instruction:
if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) {
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?