bin/140061: restore(8) increase to WARNS=2
Ulrich Spörlein
uqs at spoerlein.net
Wed Oct 28 19:30:03 UTC 2009
>Number: 140061
>Category: bin
>Synopsis: restore(8) increase to WARNS=2
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Oct 28 19:30:03 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Ulrich Spörlein
>Release: FreeBSD 9.0-CURRENT i386
>Organization:
>Environment:
>Description:
- Use casts to shutup printf(3) format warnings, I hope my choice of casts
is solid
- style Makefile, while here
>How-To-Repeat:
>Fix:
--- restore.diff begins here ---
diff -r 936c77a53c48 -r 8c486b229917 sbin/restore/Makefile
--- a/sbin/restore/Makefile Mon Oct 26 21:12:51 2009 +0100
+++ b/sbin/restore/Makefile Wed Oct 28 20:03:06 2009 +0100
@@ -5,11 +5,11 @@
PROG= restore
LINKS= ${BINDIR}/restore ${BINDIR}/rrestore
-CFLAGS+=-DRRESTORE -D_ACL_PRIVATE
-WARNS?= 0
+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
-MAN= restore.8
-MLINKS= restore.8 rrestore.8
+WARNS?= 2
+CFLAGS+= -DRRESTORE -D_ACL_PRIVATE
.include <bsd.prog.mk>
diff -r 936c77a53c48 -r 8c486b229917 sbin/restore/dirs.c
--- a/sbin/restore/dirs.c Mon Oct 26 21:12:51 2009 +0100
+++ b/sbin/restore/dirs.c Wed Oct 28 20:03:06 2009 +0100
@@ -53,6 +53,7 @@
#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 @@
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");
+ strcat(dirfile, "-XXXXXX");
fd = mkstemp(dirfile);
} else
fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666);
@@ -152,9 +153,10 @@
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");
+ strcat(modefile, "-XXXXXX");
fd = mkstemp(modefile);
} else
fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666);
@@ -257,8 +259,9 @@
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 +357,7 @@
"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 +569,8 @@
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 -r 936c77a53c48 -r 8c486b229917 sbin/restore/tape.c
--- a/sbin/restore/tape.c Mon Oct 26 21:12:51 2009 +0100
+++ b/sbin/restore/tape.c Wed Oct 28 20:03:06 2009 +0100
@@ -401,7 +401,7 @@
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,7 @@
goto again;
}
if (tmpbuf.c_volume != volno) {
- fprintf(stderr, "Wrong volume (%ld)\n", tmpbuf.c_volume);
+ fprintf(stderr, "Wrong volume (%d)\n", tmpbuf.c_volume);
volno = 0;
goto again;
}
@@ -454,8 +454,8 @@
* 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 +554,8 @@
(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 +1282,7 @@
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 +1465,8 @@
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;
--- restore.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list