Module Name: src
Committed By: christos
Date: Sun Aug 14 12:13:24 UTC 2011
Modified Files:
src/sbin/dump_lfs: Makefile lfs_inode.c
Log Message:
use a union to eliminate strict alias warnings.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/dump_lfs/Makefile
cvs rdiff -u -r1.14 -r1.15 src/sbin/dump_lfs/lfs_inode.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/dump_lfs/Makefile
diff -u src/sbin/dump_lfs/Makefile:1.12 src/sbin/dump_lfs/Makefile:1.13
--- src/sbin/dump_lfs/Makefile:1.12 Tue Jun 21 22:49:43 2011
+++ src/sbin/dump_lfs/Makefile Sun Aug 14 08:13:24 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.12 2011/06/22 02:49:43 mrg Exp $
+# $NetBSD: Makefile,v 1.13 2011/08/14 12:13:24 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93
# lfs_inode.c LFS filestore-specific routines
@@ -29,8 +29,3 @@
${NETBSDSRCDIR}/sys/ufs/ffs
.include <bsd.prog.mk>
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.lfs_inode.c+= -fno-strict-aliasing
-.endif
Index: src/sbin/dump_lfs/lfs_inode.c
diff -u src/sbin/dump_lfs/lfs_inode.c:1.14 src/sbin/dump_lfs/lfs_inode.c:1.15
--- src/sbin/dump_lfs/lfs_inode.c:1.14 Sat Jul 19 21:20:22 2008
+++ src/sbin/dump_lfs/lfs_inode.c Sun Aug 14 08:13:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.c,v 1.14 2008/07/20 01:20:22 lukem Exp $ */
+/* $NetBSD: lfs_inode.c,v 1.15 2011/08/14 12:13:24 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: lfs_inode.c,v 1.14 2008/07/20 01:20:22 lukem Exp $");
+__RCSID("$NetBSD: lfs_inode.c,v 1.15 2011/08/14 12:13:24 christos Exp $");
#endif
#endif /* not lint */
@@ -79,7 +79,11 @@
int
fs_read_sblock(char *superblock)
{
- char tbuf[LFS_SBPAD];
+ union {
+ char tbuf[LFS_SBPAD];
+ struct lfs lfss;
+ } u;
+
int ns = 0;
off_t sboff = LFS_LABELPAD;
@@ -105,23 +109,24 @@
/*
* Read the secondary and take the older of the two
*/
- rawread(fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]), tbuf, LFS_SBPAD);
+ rawread(fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]), u.tbuf,
+ sizeof(u.tbuf));
#ifdef notyet
if (ns)
- lfs_sb_swap(tbuf, tbuf, 0);
+ lfs_sb_swap(u.tbuf, u.tbuf, 0);
#endif
- if (((struct lfs *)tbuf)->lfs_magic != LFS_MAGIC) {
+ if (u.lfss.lfs_magic != LFS_MAGIC) {
msg("Warning: secondary superblock at 0x%" PRIx64 " bad magic\n",
fsbtodb(sblock, (off_t)sblock->lfs_sboffs[1]));
} else {
if (sblock->lfs_version > 1) {
- if (((struct lfs *)tbuf)->lfs_serial < sblock->lfs_serial) {
- memcpy(sblock, tbuf, LFS_SBPAD);
+ if (u.lfss.lfs_serial < sblock->lfs_serial) {
+ memcpy(sblock, u.tbuf, sizeof(u.tbuf));
sboff = fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]);
}
} else {
- if (((struct lfs *)tbuf)->lfs_otstamp < sblock->lfs_otstamp) {
- memcpy(sblock, tbuf, LFS_SBPAD);
+ if (u.lfss.lfs_otstamp < sblock->lfs_otstamp) {
+ memcpy(sblock, u.tbuf, sizeof(u.tbuf));
sboff = fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]);
}
}