Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src avoid a "multi-level non-const cast" warning from GCC 4.5.



details:   https://anonhg.NetBSD.org/src/rev/b89340a758b8
branches:  trunk
changeset: 766989:b89340a758b8
user:      mrg <mrg%NetBSD.org@localhost>
date:      Wed Jul 06 01:19:45 2011 +0000

description:
avoid a "multi-level non-const cast" warning from GCC 4.5.

diffstat:

 distrib/utils/sysinst/label.c          |  8 ++++----
 sys/arch/landisk/stand/boot/biosdisk.c |  7 +++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diffs (70 lines):

diff -r 31c1a4d7e60d -r b89340a758b8 distrib/utils/sysinst/label.c
--- a/distrib/utils/sysinst/label.c     Wed Jul 06 01:18:32 2011 +0000
+++ b/distrib/utils/sysinst/label.c     Wed Jul 06 01:19:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: label.c,v 1.56 2011/05/30 14:20:48 joerg Exp $ */
+/*     $NetBSD: label.c,v 1.57 2011/07/06 01:20:03 mrg Exp $   */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.56 2011/05/30 14:20:48 joerg Exp $");
+__RCSID("$NetBSD: label.c,v 1.57 2011/07/06 01:20:03 mrg Exp $");
 #endif
 
 #include <sys/types.h>
@@ -710,7 +710,7 @@
 get_last_mounted(int fd, int partstart, partinfo *lp)
 {
        static char sblk[SBLOCKSIZE];           /* is this enough? */
-       #define SB ((struct fs *)sblk)
+       struct fs *SB = (struct fs *)sblk;
        static const int sblocks[] = SBLOCKSEARCH;
        const int *sbp;
        char *cp;
@@ -726,7 +726,7 @@
                    partstart * (off_t)512 + *sbp) != sizeof sblk)
                        continue;
                /* Maybe we should validate the checksum??? */
-               switch (((struct fs *)sblk)->fs_magic) {
+               switch (SB->fs_magic) {
                case FS_UFS1_MAGIC:
                case FS_UFS1_MAGIC_SWAPPED:
                        if (!(SB->fs_old_flags & FS_FLAGS_UPDATED)) {
diff -r 31c1a4d7e60d -r b89340a758b8 sys/arch/landisk/stand/boot/biosdisk.c
--- a/sys/arch/landisk/stand/boot/biosdisk.c    Wed Jul 06 01:18:32 2011 +0000
+++ b/sys/arch/landisk/stand/boot/biosdisk.c    Wed Jul 06 01:19:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: biosdisk.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
+/*     $NetBSD: biosdisk.c,v 1.2 2011/07/06 01:19:45 mrg Exp $ */
 
 /*
  * Copyright (c) 1996, 1998
@@ -133,6 +133,7 @@
 static int
 read_label(struct biosdisk *d)
 {
+       struct mbr_sector *mbr_sect;
        struct disklabel dflt_lbl;
        struct mbr_partition mbr[MBR_PART_COUNT];
        struct partition *p;
@@ -158,13 +159,15 @@
        for (;;) {
                this_ext = ext_base + next_ext;
                next_ext = 0;
+               mbr_sect = (struct mbr_sector *)d->buf;
+               memcpy(&mbr, mbr_sect->mbr_parts, sizeof(mbr));
                if (readsects(d->dev, this_ext, d->buf, 1)) {
 #ifdef DISK_DEBUG
                        printf("error reading MBR sector %d\n", this_ext);
 #endif
                        return (EIO);
                }
-               memcpy(&mbr, ((struct mbr_sector *)d->buf)->mbr_parts, sizeof(mbr));
+               memcpy(&mbr, mbr_sect->mbr_parts, sizeof(mbr));
                /* Look for NetBSD partition ID */
                for (i = 0; i < MBR_PART_COUNT; i++) {
                        typ = mbr[i].mbrp_type;



Home | Main Index | Thread Index | Old Index