Author: marius
Date: Sun Mar 25 16:24:42 2012
New Revision: 233468
URL: http://svn.freebsd.org/changeset/base/233468

Log:
  MFC: r233105
  
  Declare some variables static in order to reduce the object size and
  redo r232822 (MFC'ed to stable/9 in r232962) in a less hackish way.
  The latter now no longer breaks compiling the x86 boot2 with clang.

Modified:
  stable/9/sys/boot/common/ufsread.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/i386/conf/XENHVM   (props changed)

Modified: stable/9/sys/boot/common/ufsread.c
==============================================================================
--- stable/9/sys/boot/common/ufsread.c  Sun Mar 25 16:20:01 2012        
(r233467)
+++ stable/9/sys/boot/common/ufsread.c  Sun Mar 25 16:24:42 2012        
(r233468)
@@ -46,8 +46,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/endian.h>
-
 #include <ufs/ufs/dinode.h>
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
@@ -96,7 +94,7 @@ static uint32_t fs_off;
 static __inline uint8_t
 fsfind(const char *name, ino_t * ino)
 {
-       char buf[DEV_BSIZE];
+       static char buf[DEV_BSIZE];
        struct direct *d;
        char *s;
        ssize_t n;
@@ -121,7 +119,7 @@ fsfind(const char *name, ino_t * ino)
 static ino_t
 lookup(const char *path)
 {
-       char name[MAXNAMLEN + 1];
+       static char name[MAXNAMLEN + 1];
        const char *s;
        ino_t ino;
        ssize_t n;
@@ -169,18 +167,19 @@ fsread(ino_t inode, void *buf, size_t nb
 {
 #ifndef UFS2_ONLY
        static struct ufs1_dinode dp1;
+       ufs1_daddr_t addr1;
 #endif
 #ifndef UFS1_ONLY
        static struct ufs2_dinode dp2;
 #endif
+       static struct fs fs;
        static ino_t inomap;
        char *blkbuf;
        void *indbuf;
-       struct fs fs;
        char *s;
        size_t n, nb, size, off, vboff;
        ufs_lbn_t lbn;
-       ufs2_daddr_t addr, vbaddr;
+       ufs2_daddr_t addr2, vbaddr;
        static ufs2_daddr_t blkmap, indmap;
        u_int u;
 
@@ -251,12 +250,12 @@ fsread(ino_t inode, void *buf, size_t nb
                lbn = lblkno(&fs, fs_off);
                off = blkoff(&fs, fs_off);
                if (lbn < NDADDR) {
-                       addr = DIP(di_db[lbn]);
+                       addr2 = DIP(di_db[lbn]);
                } else if (lbn < NDADDR + NINDIR(&fs)) {
                        n = INDIRPERVBLK(&fs);
-                       addr = DIP(di_ib[0]);
+                       addr2 = DIP(di_ib[0]);
                        u = (u_int)(lbn - NDADDR) / n * DBPERVBLK;
-                       vbaddr = fsbtodb(&fs, addr) + u;
+                       vbaddr = fsbtodb(&fs, addr2) + u;
                        if (indmap != vbaddr) {
                                if (dskread(indbuf, vbaddr, DBPERVBLK))
                                        return -1;
@@ -264,36 +263,24 @@ fsread(ino_t inode, void *buf, size_t nb
                        }
                        n = (lbn - NDADDR) & (n - 1);
 #if defined(UFS1_ONLY)
-#if BYTE_ORDER == BIG_ENDIAN
-                       memcpy((char *)&addr + sizeof(addr) -
-                           sizeof(ufs1_daddr_t), (ufs1_daddr_t *)indbuf + n,
-                           sizeof(ufs1_daddr_t));
-#else
-                       memcpy(&addr, (ufs1_daddr_t *)indbuf + n,
+                       memcpy(&addr1, (ufs1_daddr_t *)indbuf + n,
                            sizeof(ufs1_daddr_t));
-#endif
+                       addr2 = addr1;
 #elif defined(UFS2_ONLY)
-                       memcpy(&addr, (ufs2_daddr_t *)indbuf + n,
+                       memcpy(&addr2, (ufs2_daddr_t *)indbuf + n,
                            sizeof(ufs2_daddr_t));
 #else
-                       if (fs.fs_magic == FS_UFS1_MAGIC)
-#if BYTE_ORDER == BIG_ENDIAN
-                               memcpy((char *)&addr + sizeof(addr) -
-                                   sizeof(ufs1_daddr_t),
-                                   (ufs1_daddr_t *)indbuf + n,
-                               sizeof(ufs1_daddr_t));
-#else
-                               memcpy(&addr, (ufs1_daddr_t *)indbuf + n,
+                       if (fs.fs_magic == FS_UFS1_MAGIC) {
+                               memcpy(&addr1, (ufs1_daddr_t *)indbuf + n,
                                    sizeof(ufs1_daddr_t));
-#endif
-                       else
-                               memcpy(&addr, (ufs2_daddr_t *)indbuf + n,
+                               addr2 = addr1;
+                       } else
+                               memcpy(&addr2, (ufs2_daddr_t *)indbuf + n,
                                    sizeof(ufs2_daddr_t));
 #endif
-               } else {
+               } else
                        return -1;
-               }
-               vbaddr = fsbtodb(&fs, addr) + (off >> VBLKSHIFT) * DBPERVBLK;
+               vbaddr = fsbtodb(&fs, addr2) + (off >> VBLKSHIFT) * DBPERVBLK;
                vboff = off & VBLKMASK;
                n = sblksize(&fs, size, lbn) - (off & ~VBLKMASK);
                if (n > VBLKSIZE)
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "[email protected]"

Reply via email to