From owner-freebsd-alpha Sun Jun 23 10:31: 9 2002 Delivered-To: freebsd-alpha@freebsd.org Received: from mail.inka.de (quechua.inka.de [212.227.14.2]) by hub.freebsd.org (Postfix) with ESMTP id 054B037B42A for ; Sun, 23 Jun 2002 10:30:44 -0700 (PDT) Received: from kemoauc.mips.inka.de (uucp@) by mail.inka.de with local-bsmtp id 17MBCF-0000aX-00; Sun, 23 Jun 2002 19:30:43 +0200 Received: from kemoauc.mips.inka.de (localhost [127.0.0.1]) by kemoauc.mips.inka.de (8.12.3/8.12.2) with ESMTP id g5NGnRBD066984 for ; Sun, 23 Jun 2002 18:49:27 +0200 (CEST) (envelope-from mailnull@localhost.mips.inka.de) Received: (from mailnull@localhost) by kemoauc.mips.inka.de (8.12.3/8.12.3/Submit) id g5NGnRxi066983 for freebsd-alpha@freebsd.org; Sun, 23 Jun 2002 18:49:27 +0200 (CEST) From: naddy@mips.inka.de (Christian Weisgerber) Subject: -CURRENT: UA in locate Date: Sun, 23 Jun 2002 16:49:26 +0000 (UTC) Message-ID: Originator: naddy@mips.inka.de (Christian Weisgerber) To: freebsd-alpha@freebsd.org Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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