Date: Sun, 23 Jun 2002 16:49:26 +0000 (UTC) From: naddy@mips.inka.de (Christian Weisgerber) To: freebsd-alpha@freebsd.org Subject: -CURRENT: UA in locate Message-ID: <af4u6m$21cu$1@kemoauc.mips.inka.de>
next in thread | raw e-mail | index | archive | help
The locate(1) command throws unaligned access errors in -CURRENT. This has probably been triggered by the switch to gcc 3.1. Here's a diff with extended context to show what's going on: Index: util.c =================================================================== RCS file: /cvs/src/usr.bin/locate/locate/util.c,v retrieving revision 1.9 diff -u -U9 -r1.9 util.c --- util.c 22 Mar 2002 01:22:48 -0000 1.9 +++ util.c 23 Jun 2002 16:33:24 -0000 @@ -225,19 +225,19 @@ * Convert network byte order to host byte order if neccessary. * So we can read on FreeBSD/i386 (little endian) a locate database * which was built on SunOS/sparc (big endian). */ int getwm(p) caddr_t p; { - static char buf[INTSIZE]; + char buf[INTSIZE]; register int i; for (i = 0; i < INTSIZE; i++) buf[i] = *p++; i = *(int *)buf; if (i > MAXPATHLEN || i < -(MAXPATHLEN)) { i = ntohl(i); =================================================================== Apparently the author assumed that buf[] would be properly aligned, so that dereferencing an integer pointer would be safe. I'm at a loss how somebody can arrive at this assumption for a static object. For an automatic variable on the other hand it is a reasonable guess. Is that fix okay, or should we play games with "int buf; (char *)&buf"? -- Christian "naddy" Weisgerber naddy@mips.inka.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?af4u6m$21cu$1>