Module Name: src
Committed By: dsl
Date: Wed Aug 5 21:31:50 UTC 2009
Modified Files:
src/sbin/fdisk: fdisk.c
Log Message:
Change arguments to decimal() to be int64_t.
They need to be able to hold disk sector numbers > 2^31 and also -1.
Should fix PR/34807
To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sbin/fdisk/fdisk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/fdisk/fdisk.c
diff -u src/sbin/fdisk/fdisk.c:1.122 src/sbin/fdisk/fdisk.c:1.123
--- src/sbin/fdisk/fdisk.c:1.122 Tue Jun 2 21:15:53 2009
+++ src/sbin/fdisk/fdisk.c Wed Aug 5 21:31:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fdisk.c,v 1.122 2009/06/02 21:15:53 christos Exp $ */
+/* $NetBSD: fdisk.c,v 1.123 2009/08/05 21:31:50 dsl Exp $ */
/*
* Mach Operating System
@@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.122 2009/06/02 21:15:53 christos Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.123 2009/08/05 21:31:50 dsl Exp $");
#endif /* not lint */
#define MBRPTYPENAMES
@@ -246,7 +246,7 @@
int read_gpt(daddr_t, struct gpt_hdr *);
int delete_gpt(struct gpt_hdr *);
int yesno(const char *, ...);
-int decimal(const char *, int, int, int, int);
+int decimal(const char *, int64_t, int, int64_t, int64_t);
#define DEC_SEC 1 /* asking for a sector number */
#define DEC_RND 2 /* round to end of first track */
#define DEC_RND_0 4 /* round 0 to size of a track */
@@ -2642,19 +2642,19 @@
}
int
-decimal(const char *prompt, int dflt, int flags, int minval, int maxval)
+decimal(const char *prompt, int64_t dflt, int flags, int64_t minval, int64_t maxval)
{
- int acc = 0;
+ int64_t acc = 0;
char *cp;
char ch;
for (;;) {
if (flags & DEC_SEC) {
- printf("%s: [%d..%dcyl default: %d, %dcyl, %uMB] ",
+ printf("%s: [%" PRId64 "..%" PRId64 "dcyl default: %" PRId64 ", %" PRId64 "dcyl, %uMB] ",
prompt, SEC_TO_CYL(minval), SEC_TO_CYL(maxval),
dflt, SEC_TO_CYL(dflt), SEC_TO_MB(dflt));
} else
- printf("%s: [%d..%d default: %d] ",
+ printf("%s: [%" PRId64 "..%" PRId64 " default: %" PRId64 "] ",
prompt, minval, maxval, dflt);
if (!fgets(lbuf, LBUF, stdin))
@@ -2670,7 +2670,7 @@
return maxval;
if (isdigit((unsigned char)*cp) || *cp == '-') {
- acc = strtol(lbuf, &cp, 10);
+ acc = strtoll(lbuf, &cp, 10);
if (flags & DEC_SEC) {
ch = *cp;
if (ch == 'g' || ch == 'G') {
@@ -2709,7 +2709,7 @@
if (acc >= minval && acc <= maxval)
return acc;
- printf("%d is not between %d and %d.\n", acc, minval, maxval);
+ printf("%" PRId64 " is not between %" PRId64 " and %" PRId64 ".\n", acc, minval, maxval);
}
}