[avahi] arm memory alignment problems

Lennart Poettering lennart at poettering.de
Wed Oct 5 06:44:40 PDT 2005


On Wed, 05.10.05 15:04, pHilipp Zabel (philipp.zabel at gmail.com) wrote:

> > First you disassemble the bytes in the packet. This looks right to me.
> >
> > > +    d = (uint8_t*) ret_v;
> > > +    d[0] = ((uint8_t*)(&tmp_v))[0];
> > > +    d[1] = ((uint8_t*)(&tmp_v))[1];
> >
> > And now you copy a 16 bit value to a 16 bit value?
> >
> > What about just using *ret_v = tmp_v? Or even shorter: dumping tmp_v
> > and write directly to ret_v?
> 
> I can only do this on arm if ret_v is aligned. If ret_v is guaranteed
> to be aligned, this is indeed superfluous.

It certainly is guaranteed. That pointer points to some uint16_t
variable owned by the caller, which should be aligned. And if it isn't
it is a bug in the caller.

Lennart

-- 
Lennart Poettering; lennart [at] poettering [dot] de
ICQ# 11060553; GPG 0x1A015CC4; http://0pointer.de/lennart/


More information about the avahi mailing list