From owner-svn-src-head@FreeBSD.ORG Fri Jan 29 10:00:42 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89722106566C; Fri, 29 Jan 2010 10:00:42 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 76D458FC14; Fri, 29 Jan 2010 10:00:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0TA0goH024209; Fri, 29 Jan 2010 10:00:42 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0TA0gbM024204; Fri, 29 Jan 2010 10:00:42 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201001291000.o0TA0gbM024204@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 29 Jan 2010 10:00:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203155 - head/sbin/restore X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2010 10:00:42 -0000 Author: jh Date: Fri Jan 29 10:00:42 2010 New Revision: 203155 URL: http://svn.freebsd.org/changeset/base/203155 Log: - 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) Modified: head/sbin/restore/Makefile head/sbin/restore/dirs.c head/sbin/restore/extern.h head/sbin/restore/interactive.c head/sbin/restore/tape.c Modified: head/sbin/restore/Makefile ============================================================================== --- head/sbin/restore/Makefile Fri Jan 29 06:39:57 2010 (r203154) +++ head/sbin/restore/Makefile Fri Jan 29 10:00:42 2010 (r203155) @@ -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 Modified: head/sbin/restore/dirs.c ============================================================================== --- head/sbin/restore/dirs.c Fri Jan 29 06:39:57 2010 (r203154) +++ head/sbin/restore/dirs.c Fri Jan 29 10:00:42 2010 (r203155) @@ -53,6 +53,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -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 (* 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"); Modified: head/sbin/restore/extern.h ============================================================================== --- head/sbin/restore/extern.h Fri Jan 29 06:39:57 2010 (r203154) +++ head/sbin/restore/extern.h Fri Jan 29 10:00:42 2010 (r203155) @@ -34,7 +34,7 @@ struct entry *addentry(char *, ino_t, in 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); Modified: head/sbin/restore/interactive.c ============================================================================== --- head/sbin/restore/interactive.c Fri Jan 29 06:39:57 2010 (r203154) +++ head/sbin/restore/interactive.c Fri Jan 29 10:00:42 2010 (r203155) @@ -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; Modified: head/sbin/restore/tape.c ============================================================================== --- head/sbin/restore/tape.c Fri Jan 29 06:39:57 2010 (r203154) +++ head/sbin/restore/tape.c Fri Jan 29 10:00:42 2010 (r203155) @@ -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;