Skip to contentSkip to conversation

questionable code in glibc sunrpc code?

parisc-linux Randolph Chung 2 participants 2 messages Aug 26, 2002

lore
Share & tools
lore
#0 lore raw

glibc's sunrpc/clnt_tcp.c contains code like this:

      *(u_long *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT)
              = htonl(*(u_long *)info);

ct->ct_mcall is a char[] array that's after a struct, BYTES_PER_XDR_UNIT is 4

if sizeof(u_long) is 8, then this is an unaligned access... (gcc notices and complains loudly :-)

this code apparently works on other 64-bit archs.... anyone know how?

randolph

Signature · 3 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
#1 lore raw
Quoted 1 line

this code apparently works on other 64-bit archs.... anyone know how?

They may not require strict alignment.

Dave

Signature · 2 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)