Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Revert subr_disk_mbr.c r.1.54



details:   https://anonhg.NetBSD.org/src/rev/bc3fe5777bb2
branches:  trunk
changeset: 460888:bc3fe5777bb2
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Nov 07 20:34:29 2019 +0000

description:
Revert subr_disk_mbr.c r.1.54

Requested by <christos> as there can be a better way to fix the original
problem with alignment.

diffstat:

 sys/kern/subr_disk_mbr.c |  33 +++++++++++++++------------------
 1 files changed, 15 insertions(+), 18 deletions(-)

diffs (98 lines):

diff -r 62eb616300c8 -r bc3fe5777bb2 sys/kern/subr_disk_mbr.c
--- a/sys/kern/subr_disk_mbr.c  Thu Nov 07 20:30:49 2019 +0000
+++ b/sys/kern/subr_disk_mbr.c  Thu Nov 07 20:34:29 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_disk_mbr.c,v 1.55 2019/11/07 20:30:49 kamil Exp $ */
+/*     $NetBSD: subr_disk_mbr.c,v 1.56 2019/11/07 20:34:29 kamil Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.55 2019/11/07 20:30:49 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk_mbr.c,v 1.56 2019/11/07 20:34:29 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -586,7 +586,7 @@
 static int
 validate_label(mbr_args_t *a, uint label_sector)
 {
-       struct disklabel *dlp, tlp;
+       struct disklabel *dlp;
        char *dlp_lim, *dlp_byte;
        int error;
 #ifdef DISKLABEL_EI
@@ -622,23 +622,21 @@
                        else
                                dlp_byte += LABELSECTOR * a->lp->d_secsize;
                        dlp = (void *)dlp_byte;
-                       memcpy(&tlp, dlp, sizeof(tlp));
                        break;
                }
-               memcpy(&tlp, dlp, sizeof(tlp));
-               if (!check_label_magic(&tlp, DISKMAGIC))
+               if (!check_label_magic(dlp, DISKMAGIC))
 #ifdef DISKLABEL_EI
                {
-                       if (!check_label_magic(&tlp, bswap32(DISKMAGIC)))
+                       if (!check_label_magic(dlp, bswap32(DISKMAGIC)))
                                continue;
 
                        /*
                         * The label is in the other byte order. We need to
                         * checksum before swapping the byte order.
                         */
-                       npartitions = bswap16(tlp.d_npartitions);
+                       npartitions = bswap16(dlp->d_npartitions);
                        if (npartitions > MAXPARTITIONS ||
-                           dkcksum_sized(&tlp, npartitions) != 0)
+                           dkcksum_sized(dlp, npartitions) != 0)
                                goto corrupted;
 
                        swapped = 1;
@@ -646,8 +644,8 @@
 #else
                        continue;
 #endif
-               else if (tlp.d_npartitions > MAXPARTITIONS ||
-                        dkcksum(&tlp) != 0) {
+               else if (dlp->d_npartitions > MAXPARTITIONS ||
+                        dkcksum(dlp) != 0) {
 #ifdef DISKLABEL_EI
 corrupted:
 #endif
@@ -661,11 +659,11 @@
        case READ_LABEL:
 #ifdef DISKLABEL_EI
                if (swapped)
-                       swap_disklabel(a->lp, &tlp);
+                       swap_disklabel(a->lp, dlp);
                else
-                       *a->lp = tlp;
+                       *a->lp = *dlp;
 #else
-               *a->lp = tlp;
+               *a->lp = *dlp;
 #endif
                if ((a->msg = convertdisklabel(a->lp, a->strat, a->bp,
                                              a->secperunit)) != NULL)
@@ -677,13 +675,12 @@
 #ifdef DISKLABEL_EI
                /* DO NOT swap a->lp itself for later references. */
                if (swapped)
-                       swap_disklabel(&tlp, a->lp);
+                       swap_disklabel(dlp, a->lp);
                else
-                       tlp = *a->lp;
+                       *dlp = *a->lp;
 #else
-               tlp = *a->lp;
+               *dlp = *a->lp;
 #endif
-               memcpy(dlp, &tlp, sizeof(tlp));
                a->bp->b_oflags &= ~BO_DONE;
                a->bp->b_flags &= ~B_READ;
                a->bp->b_flags |= B_WRITE;



Home | Main Index | Thread Index | Old Index