Module Name: src Committed By: joerg Date: Thu Apr 3 18:49:41 UTC 2014
Modified Files: src/sys/arch/cobalt/stand/boot: wd.c Log Message: Avoid type pruning. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/cobalt/stand/boot/wd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/cobalt/stand/boot/wd.c diff -u src/sys/arch/cobalt/stand/boot/wd.c:1.15 src/sys/arch/cobalt/stand/boot/wd.c:1.16 --- src/sys/arch/cobalt/stand/boot/wd.c:1.15 Sun Jul 17 20:54:38 2011 +++ src/sys/arch/cobalt/stand/boot/wd.c Thu Apr 3 18:49:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.15 2011/07/17 20:54:38 joerg Exp $ */ +/* $NetBSD: wd.c,v 1.16 2014/04/03 18:49:41 joerg Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -157,6 +157,7 @@ wdgetdisklabel(struct wd_softc *wd) size_t rsize; struct disklabel *lp; uint8_t buf[DEV_BSIZE]; + uint16_t magic; wdgetdefaultlabel(wd, &wd->sc_label); @@ -167,7 +168,8 @@ wdgetdisklabel(struct wd_softc *wd) if (wdstrategy(wd, F_READ, MBR_BBSECTOR, DEV_BSIZE, buf, &rsize)) return EOFFSET; - if (*(uint16_t *)&buf[MBR_MAGIC_OFFSET] == MBR_MAGIC) { + memcpy(&magic, &buf[MBR_MAGIC_OFFSET], sizeof(magic)); + if (magic == MBR_MAGIC) { int i; struct mbr_partition *mp;