svn commit: r233105 - head/sys/boot/common
Marius Strobl
marius at FreeBSD.org
Sun Mar 18 02:19:31 UTC 2012
Author: marius
Date: Sun Mar 18 02:19:30 2012
New Revision: 233105
URL: http://svn.freebsd.org/changeset/base/233105
Log:
Declare some variables static in order to reduce the object size and
redo r232822 in a less hackish way. The latter now no longer breaks
compiling the x86 boot2 with clang.
MFC after: 1 week
Modified:
head/sys/boot/common/ufsread.c
Modified: head/sys/boot/common/ufsread.c
==============================================================================
--- head/sys/boot/common/ufsread.c Sun Mar 18 01:43:41 2012 (r233104)
+++ head/sys/boot/common/ufsread.c Sun Mar 18 02:19:30 2012 (r233105)
@@ -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)
More information about the svn-src-head
mailing list