diff options
author | iedowse <iedowse@FreeBSD.org> | 2002-07-08 23:53:21 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2002-07-08 23:53:21 +0000 |
commit | 6625a99a43044348b09bcb8fa1094f017badfde3 (patch) | |
tree | 08100af48926fc7fd4a07596305e595df3341172 /sbin | |
parent | 770030e6792e027444cdb7d8d43aa5c8c3cb9d94 (diff) | |
download | FreeBSD-src-6625a99a43044348b09bcb8fa1094f017badfde3.zip FreeBSD-src-6625a99a43044348b09bcb8fa1094f017badfde3.tar.gz |
Oops, the previous revision (1.22) introduced a potential alignment
issue, since the MAXBSIZE-sized buffers are accessed as arrays of
block pointers, but were declared as char[] arrays. Use a union to
avoid this, which also makes a number of casts unnecessary.
Pointed out by: bde
Reviewed by: bde
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dump/traverse.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index b5aab4e..733ac26 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -275,17 +275,20 @@ dirindir( long *tapesize, int nodump) { + union { + ufs1_daddr_t ufs1[MAXBSIZE / sizeof(ufs1_daddr_t)]; + ufs2_daddr_t ufs2[MAXBSIZE / sizeof(ufs2_daddr_t)]; + } idblk; int ret = 0; int i; - char idblk[MAXBSIZE]; - bread(fsbtodb(sblock, blkno), idblk, (int)sblock->fs_bsize); + bread(fsbtodb(sblock, blkno), (char *)&idblk, (int)sblock->fs_bsize); if (ind_level <= 0) { for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) { if (sblock->fs_magic == FS_UFS1_MAGIC) - blkno = ((ufs1_daddr_t *)idblk)[i]; + blkno = idblk.ufs1[i]; else - blkno = ((ufs2_daddr_t *)idblk)[i]; + blkno = idblk.ufs2[i]; if (blkno != 0) ret |= searchdir(ino, blkno, sblock->fs_bsize, *filesize, tapesize, nodump); @@ -299,9 +302,9 @@ dirindir( ind_level--; for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) { if (sblock->fs_magic == FS_UFS1_MAGIC) - blkno = ((ufs1_daddr_t *)idblk)[i]; + blkno = idblk.ufs1[i]; else - blkno = ((ufs2_daddr_t *)idblk)[i]; + blkno = idblk.ufs2[i]; if (blkno != 0) ret |= dirindir(ino, blkno, ind_level, filesize, tapesize, nodump); @@ -498,13 +501,17 @@ dumpino(union dinode *dp, ino_t ino) static void dmpindir(ino_t ino, ufs2_daddr_t blk, int ind_level, off_t *size) { + union { + ufs1_daddr_t ufs1[MAXBSIZE / sizeof(ufs1_daddr_t)]; + ufs2_daddr_t ufs2[MAXBSIZE / sizeof(ufs2_daddr_t)]; + } idblk; int i, cnt; - char idblk[MAXBSIZE]; if (blk != 0) - bread(fsbtodb(sblock, blk), idblk, (int) sblock->fs_bsize); + bread(fsbtodb(sblock, blk), (char *)&idblk, + (int)sblock->fs_bsize); else - memset(idblk, 0, (int)sblock->fs_bsize); + memset(&idblk, 0, sblock->fs_bsize); if (ind_level <= 0) { if (*size < NINDIR(sblock) * sblock->fs_bsize) cnt = howmany(*size, sblock->fs_fsize); @@ -512,19 +519,17 @@ dmpindir(ino_t ino, ufs2_daddr_t blk, int ind_level, off_t *size) cnt = NINDIR(sblock) * sblock->fs_frag; *size -= NINDIR(sblock) * sblock->fs_bsize; if (sblock->fs_magic == FS_UFS1_MAGIC) - ufs1_blksout((ufs1_daddr_t *)idblk, cnt, ino); + ufs1_blksout(idblk.ufs1, cnt, ino); else - ufs2_blksout((ufs2_daddr_t *)idblk, cnt, ino); + ufs2_blksout(idblk.ufs2, cnt, ino); return; } ind_level--; for (i = 0; i < NINDIR(sblock); i++) { if (sblock->fs_magic == FS_UFS1_MAGIC) - dmpindir(ino, ((ufs1_daddr_t *)idblk)[i], ind_level, - size); + dmpindir(ino, idblk.ufs1[i], ind_level, size); else - dmpindir(ino, ((ufs2_daddr_t *)idblk)[i], ind_level, - size); + dmpindir(ino, idblk.ufs2[i], ind_level, size); if (*size <= 0) return; } |