summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2013-09-10 15:17:46 +0000
committerkrw <krw@openbsd.org>2013-09-10 15:17:46 +0000
commiteafadddf078952db5decce95861fc9710553e455 (patch)
tree3455f5041bee258ed25acc940d6c3ec7996968a3
parentMake splassert for IPL_NONE fail, if we're in interrupt context. (diff)
downloadwireguard-openbsd-eafadddf078952db5decce95861fc9710553e455.tar.xz
wireguard-openbsd-eafadddf078952db5decce95861fc9710553e455.zip
The rule is: daddr_t variables hold counts of 512-byte blocks, a.k.a.
DEV_BSIZE blocks. Counts of possibly other-sized blocks (e.g. disk sector addresses) are u_int64_t. The values stored in disklabels are counts of possibly other-sized blocks and hence should be handled with u_int64_t variables. Start enforcing this rule. No intended functional change. Rule strongly suggested by deraadt@
-rw-r--r--sbin/disklabel/disklabel.c8
-rw-r--r--sbin/disklabel/editor.c16
2 files changed, 12 insertions, 12 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 8d3af18e269..97f11b55014 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.187 2013/06/18 18:24:15 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.188 2013/09/10 15:17:46 krw Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -716,7 +716,7 @@ char
canonical_unit(struct disklabel *lp, char unit)
{
struct partition *pp;
- daddr_t small;
+ u_int64_t small;
int i;
if (unit == '*') {
@@ -1379,13 +1379,13 @@ setbootflag(struct disklabel *lp)
{
struct partition *pp;
int i, errors = 0;
- daddr_t bend;
+ u_int64_t bend;
char part;
if (bootbuf == NULL)
return;
- bend = bootsize / lp->d_secsize;
+ bend = (u_int64_t)bootsize / lp->d_secsize;
for (i = 0; i < lp->d_npartitions; i++) {
if (i == RAW_PART)
/* It will *ALWAYS* overlap 'c'. */
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 0a461aa71c3..f74f5244b65 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.271 2013/06/11 16:42:04 deraadt Exp $ */
+/* $OpenBSD: editor.c,v 1.272 2013/09/10 15:17:46 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -62,8 +62,8 @@ struct mountinfo {
/* used when allocating all space according to recommendations */
struct space_allocation {
- daddr_t minsz; /* starts as blocks, xlated to sectors. */
- daddr_t maxsz; /* starts as blocks, xlated to sectors. */
+ u_int64_t minsz; /* starts as blocks, xlated to sectors. */
+ u_int64_t maxsz; /* starts as blocks, xlated to sectors. */
int rate; /* % of extra space to use */
char *mp;
};
@@ -529,7 +529,7 @@ editor_allocspace(struct disklabel *lp_org)
struct space_allocation *ap;
struct partition *pp;
struct diskchunk *chunks;
- daddr_t secs, chunkstart, chunksize, cylsecs, totsecs, xtrasecs;
+ u_int64_t chunkstart, chunksize, cylsecs, secs, totsecs, xtrasecs;
char **partmp;
int i, j, lastalloc, index = 0, fragsize, partno;
int64_t physmem;
@@ -539,7 +539,7 @@ editor_allocspace(struct disklabel *lp_org)
overlap = 0;
for (i = 0; i < MAXPARTITIONS; i++) {
- daddr_t psz, pstart, pend;
+ u_int64_t psz, pstart, pend;
pp = &lp_org->d_partitions[i];
psz = DL_GETPSIZE(pp);
@@ -709,9 +709,9 @@ editor_resize(struct disklabel *lp, char *p)
{
struct disklabel label;
struct partition *pp, *prev;
- daddr_t secs, sz, off;
+ u_int64_t secs, sz, off;
#ifdef SUN_CYLCHECK
- daddr_t cylsecs;
+ u_int64_t cylsecs;
#endif
int partno, i;
@@ -2318,7 +2318,7 @@ max_partition_size(struct disklabel *lp, int partno)
}
void
-psize(daddr_t sz, char unit, struct disklabel *lp)
+psize(u_int64_t sz, char unit, struct disklabel *lp)
{
double d = scale(sz, unit, lp);
if (d < 0)