lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #33485] SOCK_ADDR_TYPE_MATCH and SOCK_ADDR_TYPE_MATCH_


From: Bill Auerbach
Subject: [lwip-devel] [bug #33485] SOCK_ADDR_TYPE_MATCH and SOCK_ADDR_TYPE_MATCH_OR_UNSPEC use error
Date: Mon, 06 Jun 2011 18:09:25 +0000
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

Follow-up Comment #2, bug #33485 (project lwip):

>From patch:


/** A struct sockaddr replacement that has the same alignment as sockaddr_in/
186               *  sockaddr_in6 if instantiated.
187               */


On some 32-bit platforms you could wind up with 16 bytes taken up before the
sa_data member.  This *might* be more portable and smaller:


 struct sockaddr_aligned {
           u8_t  sa_len;
           u8_t  sa_family;
           unsigned :16;
         #if LWIP_IPV6
           u8_t sa_data[SIN_ZERO_LEN + 8];
         #else /* LWIP_IPV6 */
           u8_t sa_data[SIN_ZERO_LEN];
         #endif /* LWIP_IPV6 */
         };


or use a u8_t dummy[2]; for the :16.

---

Casting throws away what a compiler knows about alignment of an expression. 
So I'm not sure the cast to void * is sound across all platforms.  I believe a
cast of (struct sockaddr_in*) will cause the compiler to assume the address is
aligned (since any instance of a sockaddr it would have aligned).  If you know
it to be aligned, then the (void *) isn't needed, is it?

The summary is what you find and fix for your platform(s) might not
necessarily work everywhere.  I think the less casting that is done the
better.

But I don't know for sure - what you have could be fine everywhere.



    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?33485>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]