Date: Sun, 25 Mar 2012 16:25:18 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r233470 - stable/7/sys/boot/common Message-ID: <201203251625.q2PGPIWt089944@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Sun Mar 25 16:25:18 2012 New Revision: 233470 URL: http://svn.freebsd.org/changeset/base/233470 Log: MFC: r233105 Declare some variables static in order to reduce the object size and redo r232822 (MFC'ed to stable/7 in r232966) in a less hackish way. Modified: stable/7/sys/boot/common/ufsread.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/boot/common/ufsread.c ============================================================================== --- stable/7/sys/boot/common/ufsread.c Sun Mar 25 16:24:53 2012 (r233469) +++ stable/7/sys/boot/common/ufsread.c Sun Mar 25 16:25:18 2012 (r233470) @@ -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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203251625.q2PGPIWt089944>