summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2014-06-13 20:43:06 +0000
committernaddy <naddy@openbsd.org>2014-06-13 20:43:06 +0000
commit0603cbef045c8049765b31a5cd01e37a415cb6b1 (patch)
treeca21412737f0afc7e7f292198830ad79a3008d95
parentFor now... assume success of getentropy() just like we assumed success (diff)
downloadwireguard-openbsd-0603cbef045c8049765b31a5cd01e37a415cb6b1.tar.xz
wireguard-openbsd-0603cbef045c8049765b31a5cd01e37a415cb6b1.zip
Type cleanup:
* Move all off_t variables that don't look like file sizes to int64_t. * Switch blockswritten to int64_t, so it won't wrap at 2TB. * Same for blocksthisvol (from deraadt@). * Switch xferrate (from tedu@) and blocksperfile from long to uint64_t. * Since blocksperfile can be set with -B, move numarg() from long to long long and don't mark small integer constant arguments as long. ok deraadt@, tedu@
-rw-r--r--sbin/dump/dump.h19
-rw-r--r--sbin/dump/main.c28
-rw-r--r--sbin/dump/tape.c9
-rw-r--r--sbin/dump/traverse.c26
4 files changed, 42 insertions, 40 deletions
diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h
index 3c172247c92..4a72c2f9102 100644
--- a/sbin/dump/dump.h
+++ b/sbin/dump/dump.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.h,v 1.19 2014/05/24 21:49:09 krw Exp $ */
+/* $OpenBSD: dump.h,v 1.20 2014/06/13 20:43:06 naddy Exp $ */
/* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */
/*-
@@ -65,15 +65,15 @@ int pipeout; /* true => output to standard output */
ino_t curino; /* current inumber; used globally */
int newtape; /* new tape flag */
int density; /* density in 0.1" units */
-off_t tapesize; /* estimated tape size, blocks */
-off_t tsize; /* tape size in 0.1" units */
+int64_t tapesize; /* estimated tape size, blocks */
+int64_t tsize; /* tape size in 0.1" units */
int unlimited; /* if set, write to end of medium */
-off_t asize; /* number of 0.1" units written on current tape */
+int64_t asize; /* number of 0.1" units written on current tape */
int etapes; /* estimated number of tapes */
int nonodump; /* if set, do not honor UF_NODUMP user flags */
int notify; /* notify operator flag */
-int blockswritten; /* number of blocks written on current tape */
+int64_t blockswritten; /* number of blocks written on current tape */
int tapeno; /* current tape number */
time_t tstart_writing; /* when started writing the first tape block */
long xferrate; /* averaged transfer rate of all volumes */
@@ -96,10 +96,11 @@ void timeest(void);
/* mapping routines */
union dinode;
-off_t blockest(union dinode *dp);
-void mapfileino(ino_t, off_t *, int *);
-int mapfiles(ino_t maxino, off_t *tapesize, char *disk, char * const *dirv);
-int mapdirs(ino_t maxino, off_t *tapesize);
+int64_t blockest(union dinode *dp);
+void mapfileino(ino_t, int64_t *, int *);
+int mapfiles(ino_t maxino, int64_t *tapesize, char *disk,
+ char * const *dirv);
+int mapdirs(ino_t maxino, int64_t *tapesize);
/* file dumping routines */
void ufs1_blksout(int32_t *blkp, int frags, ino_t ino);
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index b0a904800bc..3f878ea546b 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.50 2014/05/31 08:28:13 jmc Exp $ */
+/* $OpenBSD: main.c,v 1.51 2014/06/13 20:43:06 naddy Exp $ */
/* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */
/*-
@@ -59,12 +59,12 @@
#include "pathnames.h"
int notify = 0; /* notify operator flag */
-int blockswritten = 0; /* number of blocks written on current tape */
+int64_t blockswritten = 0; /* number of blocks written on current tape */
int tapeno = 0; /* current tape number */
int density = 0; /* density in bytes/0.1" */
int ntrec = NTREC; /* # tape blocks in each tape record */
int cartridge = 0; /* Assume non-cartridge tape */
-long blocksperfile; /* output blocks per file */
+int64_t blocksperfile; /* output blocks per file */
char *host = NULL; /* remote host (if any) */
int maxbsize = 64*1024; /* XXX MAXBSIZE from sys/param.h */
@@ -75,7 +75,7 @@ struct disklabel lab;
*/
static int sblock_try[] = SBLOCKSEARCH;
-static long numarg(char *, long, long);
+static long long numarg(char *, long long, long long);
static void obsolete(int *, char **[]);
static void usage(void);
@@ -121,11 +121,11 @@ main(int argc, char *argv[])
break;
case 'B': /* blocks per output file */
- blocksperfile = numarg("blocks per file", 1L, 0L);
+ blocksperfile = numarg("blocks per file", 1, 0);
break;
case 'b': /* blocks per tape write */
- ntrec = numarg("blocks per write", 1L, 1000L);
+ ntrec = numarg("blocks per write", 1, 1000);
if (ntrec > maxbsize/1024) {
msg("Please choose a blocksize <= %dKB\n",
maxbsize/1024);
@@ -139,7 +139,7 @@ main(int argc, char *argv[])
break;
case 'd': /* density, in bits per inch */
- density = numarg("density", 10L, 327670L) / 10;
+ density = numarg("density", 10, 327670) / 10;
if (density >= 625 && !bflag)
ntrec = HIGHDENSITYTREC;
break;
@@ -149,7 +149,7 @@ main(int argc, char *argv[])
break;
case 'h':
- honorlevel = numarg("honor level", 0L, 10L);
+ honorlevel = numarg("honor level", 0, 10);
break;
case 'n': /* notify operators */
@@ -157,7 +157,7 @@ main(int argc, char *argv[])
break;
case 's': /* tape size, feet */
- tsize = numarg("tape size", 1L, 0L) * 12 * 10;
+ tsize = numarg("tape size", 1, 0) * 12 * 10;
break;
case 'S': /* estimate blocks and # of tapes */
@@ -573,17 +573,17 @@ usage(void)
* Pick up a numeric argument. It must be nonnegative and in the given
* range (except that a vmax of 0 means unlimited).
*/
-static long
-numarg(char *meaning, long vmin, long vmax)
+static long long
+numarg(char *meaning, long long vmin, long long vmax)
{
- long val;
+ long long val;
const char *errstr;
if (vmax == 0)
- vmax = LONG_MAX;
+ vmax = LLONG_MAX;
val = strtonum(optarg, vmin, vmax, &errstr);
if (errstr)
- errx(X_STARTUP, "%s is %s [%ld - %ld]",
+ errx(X_STARTUP, "%s is %s [%lld - %lld]",
meaning, errstr, vmin, vmax);
return (val);
diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c
index a64bd6b9fbf..14b4df1602d 100644
--- a/sbin/dump/tape.c
+++ b/sbin/dump/tape.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tape.c,v 1.39 2014/05/24 21:49:09 krw Exp $ */
+/* $OpenBSD: tape.c,v 1.40 2014/06/13 20:43:06 naddy Exp $ */
/* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */
/*-
@@ -56,8 +56,8 @@
int writesize; /* size of malloc()ed buffer for tape */
int64_t lastspclrec = -1; /* tape block number of last written header */
int trecno = 0; /* next record to write in current block */
-extern long blocksperfile; /* number of blocks per output file */
-long blocksthisvol; /* number of blocks on current output file */
+extern int64_t blocksperfile; /* number of blocks per output file */
+int64_t blocksthisvol; /* number of blocks on current output file */
extern int ntrec; /* blocking factor on tape */
extern int cartridge;
extern char *host;
@@ -200,7 +200,8 @@ tperror(int signo)
quit("Cannot recover\n");
/* NOTREACHED */
}
- msg("write error %ld blocks into volume %d\n", blocksthisvol, tapeno);
+ msg("write error %lld blocks into volume %d\n",
+ (long long)blocksthisvol, tapeno);
broadcast("DUMP WRITE ERROR!\n");
if (!query("Do you want to restart?"))
dumpabort(0);
diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c
index 0368adfb032..0d786fef5e1 100644
--- a/sbin/dump/traverse.c
+++ b/sbin/dump/traverse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traverse.c,v 1.34 2014/05/31 14:15:22 krw Exp $ */
+/* $OpenBSD: traverse.c,v 1.35 2014/06/13 20:43:06 naddy Exp $ */
/* $NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $ */
/*-
@@ -63,9 +63,9 @@ union dinode {
#define HASDUMPEDFILE 0x1
#define HASSUBDIRS 0x2
-static int dirindir(ino_t, daddr_t, int, off_t *, off_t *, int);
+static int dirindir(ino_t, daddr_t, int, off_t *, int64_t *, int);
static void dmpindir(ino_t, daddr_t, int, off_t *);
-static int searchdir(ino_t, daddr_t, long, off_t, off_t *, int);
+static int searchdir(ino_t, daddr_t, long, off_t, int64_t *, int);
void fs_mapinodes(ino_t maxino, off_t *tapesize, int *anydirskipped);
/*
@@ -75,10 +75,10 @@ void fs_mapinodes(ino_t maxino, off_t *tapesize, int *anydirskipped);
* (when some of the blocks are usually used for indirect pointers);
* hence the estimate may be high.
*/
-off_t
+int64_t
blockest(union dinode *dp)
{
- off_t blkest, sizeest;
+ int64_t blkest, sizeest;
/*
* dp->di_size is the size of the file in bytes.
@@ -94,8 +94,8 @@ blockest(union dinode *dp)
* dump blocks (sizeest vs. blkest in the indirect block
* calculation).
*/
- blkest = howmany(dbtob((off_t)DIP(dp, di_blocks)), TP_BSIZE);
- sizeest = howmany((off_t)DIP(dp, di_size), TP_BSIZE);
+ blkest = howmany(dbtob((int64_t)DIP(dp, di_blocks)), TP_BSIZE);
+ sizeest = howmany((int64_t)DIP(dp, di_size), TP_BSIZE);
if (blkest > sizeest)
blkest = sizeest;
if (DIP(dp, di_size) > sblock->fs_bsize * NDADDR) {
@@ -115,7 +115,7 @@ blockest(union dinode *dp)
* Determine if given inode should be dumped
*/
void
-mapfileino(ino_t ino, off_t *tapesize, int *dirskipped)
+mapfileino(ino_t ino, int64_t *tapesize, int *dirskipped)
{
int mode;
union dinode *dp;
@@ -144,7 +144,7 @@ mapfileino(ino_t ino, off_t *tapesize, int *dirskipped)
}
void
-fs_mapinodes(ino_t maxino, off_t *tapesize, int *anydirskipped)
+fs_mapinodes(ino_t maxino, int64_t *tapesize, int *anydirskipped)
{
int i, cg, inosused;
struct cg *cgp;
@@ -204,7 +204,7 @@ fs_mapinodes(ino_t maxino, off_t *tapesize, int *anydirskipped)
* the directories in the filesystem.
*/
int
-mapfiles(ino_t maxino, off_t *tapesize, char *disk, char * const *dirv)
+mapfiles(ino_t maxino, int64_t *tapesize, char *disk, char * const *dirv)
{
int anydirskipped = 0;
@@ -304,7 +304,7 @@ mapfiles(ino_t maxino, off_t *tapesize, char *disk, char * const *dirv)
* pass using this algorithm.
*/
int
-mapdirs(ino_t maxino, off_t *tapesize)
+mapdirs(ino_t maxino, int64_t *tapesize)
{
union dinode *dp;
int i, isdir, nodump;
@@ -382,7 +382,7 @@ mapdirs(ino_t maxino, off_t *tapesize)
*/
static int
dirindir(ino_t ino, daddr_t blkno, int ind_level, off_t *filesize,
- off_t *tapesize, int nodump)
+ int64_t *tapesize, int nodump)
{
int ret = 0;
int i;
@@ -425,7 +425,7 @@ dirindir(ino_t ino, daddr_t blkno, int ind_level, off_t *filesize,
*/
static int
searchdir(ino_t ino, daddr_t blkno, long size, off_t filesize,
- off_t *tapesize, int nodump)
+ int64_t *tapesize, int nodump)
{
struct direct *dp;
union dinode *ip;