[En-Nut-Discussion] TCP/IP problems with httpd

Thiago A. Corrêa thiago.correa at gmail.com
Tue Jan 11 19:21:25 CET 2011


Hi,

On Tue, Jan 11, 2011 at 3:56 PM, Ole Reinhardt
<ole.reinhardt at embedded-it.de> wrote:

> The changes of r3170 look a little strange to me, I have to
> verify/understand this patch tomorrow.
>
> But currently I don't see a problem with alignment, as (hopefully) the
> compiler should fix this and just generate correctly alligned code.
>

Well, I can't say I have very good understanding of alignment issues,
but before that patch, the code did byte access to the memory, and
it's always ok. Then it was changed to cast to ushort a position in
memory that's inside the network buffer. Since network buffer is a
byte array, there is nothing that really enforces the alignment. The
buffer might be aligned at it's start, but not at that field's start
address inside the buffer.

As I said, I haven't hit that as an issue, but it looks like it could
be an issue, perhaps at other platforms that have different alignment
boundary requirements or perhaps I just had happy coincidences.
If the AVR32 code were to reach an alighnment exception, I would have
seen it in the debugger, as the execution is trapped inside an
infinite loop, and stopping the debugger drops me there.

Also, there is something that bother's me with that code + description.
Unlike the description, both versions of the code swaps correctly and
nothing should be advertised wrongly as far as I can see.
If you ignore the alignment issues, it would only make a difference in
LE platforms, as the cast incorrectly interprets that memory as a LE
short, but then ntohs isn't a nop in LE and should bswap it as
expected.

Am I assuming something wrong?

Kind Regards,
    Thiago A. Correa



More information about the En-Nut-Discussion mailing list