Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dkwedge determine the buffer size by roundup(9)
details: https://anonhg.NetBSD.org/src/rev/a42223fc4325
branches: trunk
changeset: 351823:a42223fc4325
user: rin <rin%NetBSD.org@localhost>
date: Tue Feb 28 04:46:02 2017 +0000
description:
determine the buffer size by roundup(9)
diffstat:
sys/dev/dkwedge/dkwedge_rdb.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diffs (44 lines):
diff -r beb2ee45b324 -r a42223fc4325 sys/dev/dkwedge/dkwedge_rdb.c
--- a/sys/dev/dkwedge/dkwedge_rdb.c Tue Feb 28 04:39:58 2017 +0000
+++ b/sys/dev/dkwedge/dkwedge_rdb.c Tue Feb 28 04:46:02 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkwedge_rdb.c,v 1.2 2017/02/28 04:39:58 rin Exp $ */
+/* $NetBSD: dkwedge_rdb.c,v 1.3 2017/02/28 04:46:02 rin Exp $ */
/*
* Adapted from arch/amiga/amiga/disksubr.c:
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.2 2017/02/28 04:39:58 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_rdb.c,v 1.3 2017/02/28 04:46:02 rin Exp $");
#include <sys/param.h>
#include <sys/disklabel_rdb.h>
@@ -124,9 +124,8 @@
bool found, root, swap;
secsize = bufsize = DEV_BSIZE << pdk->dk_blkshift;
- while (bufsize < sizeof(struct partblock) ||
- bufsize < sizeof(struct rdblock))
- bufsize *= 2;
+ bufsize = roundup(MAX(sizeof(struct partblock), sizeof(struct rdblock)),
+ secsize);
bp = DKW_MALLOC(bufsize);
/*
@@ -160,10 +159,9 @@
if (secsize != newsecsize) {
aprint_verbose("secsize changed from %u to %u\n",
secsize, newsecsize);
- secsize = bufsize = newsecsize;
- while (bufsize < sizeof(struct partblock) ||
- bufsize < sizeof(struct rdblock))
- bufsize *= 2;
+ secsize = newsecsize;
+ bufsize = roundup(MAX(sizeof(struct partblock),
+ sizeof(struct rdblock)), secsize);
bp = DKW_REALLOC(bp, bufsize);
}
Home |
Main Index |
Thread Index |
Old Index