lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t)


From: Simon Goldschmidt
Subject: [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t)
Date: Fri, 14 May 2010 10:50:54 +0000
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3

Follow-up Comment #46, bug #27352 (project lwip):

Well, of course I can create an unaligned u32_t pointer if I want to. In
fact, lwIP does this trick in some places and ensures correct alignment by
adding its own defines. However, if I don't take the detour of using a
void-pointer, the compiler warns me:

u8_t *a = &some_u8t;
u32_t *b = (u32_t*)a; <<-- compiler warns
u32_t *c = (u32_t*)(void*)a; <<-- compiler doesn't warn

If we only used the 1st cast, what could go wrong? How could it give an
unaligned type? An of course, the next lines give warnings, too:

typedef u32_t some_type_t;
some_type_t *d = (some_type_t)a;

So far so good. However, I would have expected to be warned when casting from
a (possibly) unaligned u32_t member of a packed struct to an u32_t pointer
(that requires alignment), but it seems I have been wrong there.

Being like that, we need some other guards here to prevent creating unaligned
pointers.

    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/




reply via email to

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