summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2010-01-29 10:00:42 +0000
committerjh <jh@FreeBSD.org>2010-01-29 10:00:42 +0000
commit9ae99f1d1fd62ac580036a82d78b8f3187e6809d (patch)
treeca10ee7c75f6ff15c719f152e3b1323aa4e85361 /sbin
parentc449575654a479b13a6ac6eed1cc7f390cf50172 (diff)
downloadFreeBSD-src-9ae99f1d1fd62ac580036a82d78b8f3187e6809d.zip
FreeBSD-src-9ae99f1d1fd62ac580036a82d78b8f3187e6809d.tar.gz
- Cast time_t, int64_t and some int32_t values to intmax_t and use "%jd"
in format strings. - Use (void) instead of (void *) when discarding strcat(3) return value. - Format string fixes to match variable types. - Change canon() len parameter and getcmd() size parameter type from int to size_t. - Style Makefile and increase WARNS to 2. PR: bin/140061 Submitted by: uqs Approved by: trasz (mentor)
Diffstat (limited to 'sbin')
-rw-r--r--sbin/restore/Makefile8
-rw-r--r--sbin/restore/dirs.c19
-rw-r--r--sbin/restore/extern.h2
-rw-r--r--sbin/restore/interactive.c6
-rw-r--r--sbin/restore/tape.c19
5 files changed, 29 insertions, 25 deletions
diff --git a/sbin/restore/Makefile b/sbin/restore/Makefile
index 8097190..c462f51 100644
--- a/sbin/restore/Makefile
+++ b/sbin/restore/Makefile
@@ -5,11 +5,11 @@
PROG= restore
LINKS= ${BINDIR}/restore ${BINDIR}/rrestore
-CFLAGS+=-DRRESTORE -D_ACL_PRIVATE
-WARNS?= 0
-SRCS= main.c interactive.c restore.c dirs.c symtab.c tape.c utilities.c \
- dumprmt.c
MAN= restore.8
MLINKS= restore.8 rrestore.8
+SRCS= main.c interactive.c restore.c dirs.c symtab.c tape.c utilities.c \
+ dumprmt.c
+WARNS?= 2
+CFLAGS+= -DRRESTORE -D_ACL_PRIVATE
.include <bsd.prog.mk>
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index 91bdcd4..203d977 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -53,6 +53,7 @@ static const char rcsid[] =
#include <errno.h>
#include <limits.h>
#include <paths.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -139,9 +140,9 @@ extractdirs(int genmode)
vprintf(stdout, "Extract directories from tape\n");
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0')
tmpdir = _PATH_TMP;
- (void) sprintf(dirfile, "%s/rstdir%ld", tmpdir, dumpdate);
+ (void) sprintf(dirfile, "%s/rstdir%jd", tmpdir, (intmax_t)dumpdate);
if (command != 'r' && command != 'R') {
- (void *) strcat(dirfile, "-XXXXXX");
+ (void) strcat(dirfile, "-XXXXXX");
fd = mkstemp(dirfile);
} else
fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666);
@@ -152,9 +153,10 @@ extractdirs(int genmode)
done(1);
}
if (genmode != 0) {
- (void) sprintf(modefile, "%s/rstmode%ld", tmpdir, dumpdate);
+ (void) sprintf(modefile, "%s/rstmode%jd", tmpdir,
+ (intmax_t)dumpdate);
if (command != 'r' && command != 'R') {
- (void *) strcat(modefile, "-XXXXXX");
+ (void) strcat(modefile, "-XXXXXX");
fd = mkstemp(modefile);
} else
fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666);
@@ -257,8 +259,8 @@ treescan(char *pname, ino_t ino, long (*todo)(char *, ino_t, int))
while (dp != NULL) {
locname[namelen] = '\0';
if (namelen + dp->d_namlen >= sizeof(locname)) {
- fprintf(stderr, "%s%s: name exceeds %d char\n",
- locname, dp->d_name, sizeof(locname) - 1);
+ fprintf(stderr, "%s%s: name exceeds %zu char\n",
+ locname, dp->d_name, sizeof(locname) - 1);
} else {
(void)strlcat(locname, dp->d_name, sizeof(locname));
treescan(locname, dp->d_ino, todo);
@@ -354,7 +356,7 @@ putdir(char *buf, long size)
"reclen not multiple of 4 ");
if (dp->d_reclen < DIRSIZ(0, dp))
vprintf(stdout,
- "reclen less than DIRSIZ (%d < %d) ",
+ "reclen less than DIRSIZ (%d < %zu) ",
dp->d_reclen, DIRSIZ(0, dp));
#if NAME_MAX < 255
if (dp->d_namlen > NAME_MAX)
@@ -566,7 +568,8 @@ setdirmodes(int flags)
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0')
tmpdir = _PATH_TMP;
if (command == 'r' || command == 'R')
- (void) sprintf(modefile, "%s/rstmode%ld", tmpdir, dumpdate);
+ (void) sprintf(modefile, "%s/rstmode%jd", tmpdir,
+ (intmax_t)dumpdate);
if (modefile[0] == '#') {
panic("modefile not defined\n");
fprintf(stderr, "directory mode, owner, and times not set\n");
diff --git a/sbin/restore/extern.h b/sbin/restore/extern.h
index cbecc86..7b744e2 100644
--- a/sbin/restore/extern.h
+++ b/sbin/restore/extern.h
@@ -34,7 +34,7 @@ struct entry *addentry(char *, ino_t, int);
long addfile(char *, ino_t, int);
int addwhiteout(char *);
void badentry(struct entry *, char *);
-void canon(char *, char *, int);
+void canon(char *, char *, size_t);
void checkrestore(void);
void closemt(void);
void createfiles(void);
diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c
index c977df1..3cd311d 100644
--- a/sbin/restore/interactive.c
+++ b/sbin/restore/interactive.c
@@ -83,7 +83,7 @@ struct arglist {
static char *copynext(char *, char *);
static int fcmp(const void *, const void *);
static void formatf(struct afile *, int);
-static void getcmd(char *, char *, char *, int, struct arglist *);
+static void getcmd(char *, char *, char *, size_t, struct arglist *);
struct dirent *glob_readdir(void *);
static int glob_stat(const char *, struct stat *);
static void mkentry(char *, struct direct *, struct afile *);
@@ -301,7 +301,7 @@ loop:
* eliminate any embedded ".." components.
*/
static void
-getcmd(char *curdir, char *cmd, char *name, int size, struct arglist *ap)
+getcmd(char *curdir, char *cmd, char *name, size_t size, struct arglist *ap)
{
char *cp;
static char input[BUFSIZ];
@@ -441,7 +441,7 @@ copynext(char *input, char *output)
* remove any embedded "." and ".." components.
*/
void
-canon(char *rawname, char *canonname, int len)
+canon(char *rawname, char *canonname, size_t len)
{
char *cp, *np;
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index debed5f..6509031 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -401,7 +401,7 @@ again:
char volno[sizeof("2147483647")];
getpipecmdhdr:
- (void)sprintf(volno, "%d", newvol);
+ (void)sprintf(volno, "%ld", newvol);
if (setenv("RESTORE_VOLUME", volno, 1) == -1) {
fprintf(stderr, "Cannot set $RESTORE_VOLUME: %s\n",
strerror(errno));
@@ -433,7 +433,8 @@ gethdr:
goto again;
}
if (tmpbuf.c_volume != volno) {
- fprintf(stderr, "Wrong volume (%ld)\n", tmpbuf.c_volume);
+ fprintf(stderr, "Wrong volume (%jd)\n",
+ (intmax_t)tmpbuf.c_volume);
volno = 0;
goto again;
}
@@ -454,8 +455,8 @@ gethdr:
* If coming to this volume at random, skip to the beginning
* of the next record.
*/
- dprintf(stdout, "last rec %qd, tape starts with %qd\n", prevtapea,
- tmpbuf.c_tapea);
+ dprintf(stdout, "last rec %jd, tape starts with %jd\n",
+ (intmax_t)prevtapea, (intmax_t)tmpbuf.c_tapea);
if (tmpbuf.c_type == TS_TAPE) {
if (curfile.action != USING) {
/*
@@ -554,8 +555,8 @@ printdumpinfo(void)
(spcl.c_ddate == 0) ? "the epoch\n" : ctime(&t));
if (spcl.c_host[0] == '\0')
return;
- fprintf(stderr, "Level %ld dump of %s on %s:%s\n",
- spcl.c_level, spcl.c_filesys, spcl.c_host, spcl.c_dev);
+ fprintf(stderr, "Level %jd dump of %s on %s:%s\n",
+ (intmax_t)spcl.c_level, spcl.c_filesys, spcl.c_host, spcl.c_dev);
fprintf(stderr, "Label: %s\n", spcl.c_label);
}
@@ -1282,7 +1283,7 @@ getmore:
return;
}
if (rd % TP_BSIZE != 0)
- panic("partial block read: %d should be %d\n",
+ panic("partial block read: %ld should be %ld\n",
rd, ntrec * TP_BSIZE);
terminateinput();
memmove(&tapebuf[rd], &endoftapemark, (long)TP_BSIZE);
@@ -1465,8 +1466,8 @@ accthdr(struct s_spcl *header)
if (header->c_type == TS_TAPE) {
fprintf(stderr, "Volume header ");
if (header->c_firstrec)
- fprintf(stderr, "begins with record %qd",
- header->c_firstrec);
+ fprintf(stderr, "begins with record %jd",
+ (intmax_t)header->c_firstrec);
fprintf(stderr, "\n");
previno = 0x7fffffff;
return;
OpenPOWER on IntegriCloud