From uqs@spoerlein.net  Wed Oct 28 19:24:37 2009
Return-Path: <uqs@spoerlein.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 931FE1065679
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 28 Oct 2009 19:24:33 +0000 (UTC)
	(envelope-from uqs@spoerlein.net)
Received: from acme.spoerlein.net (cl-43.dus-01.de.sixxs.net [IPv6:2a01:198:200:2a::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 31E578FC1D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 28 Oct 2009 19:24:33 +0000 (UTC)
Received: from roadrunner.spoerlein.net (pD9E5F210.dip.t-dialin.net [217.229.242.16])
	by acme.spoerlein.net (8.14.3/8.14.3) with ESMTP id n9SJOSdh020400
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 28 Oct 2009 20:24:31 +0100 (CET)
	(envelope-from uqs@spoerlein.net)
Received: from roadrunner.spoerlein.net (localhost [127.0.0.1])
	by roadrunner.spoerlein.net (8.14.3/8.14.3) with ESMTP id n9SJO9cx004591
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Wed, 28 Oct 2009 20:24:09 +0100 (CET)
	(envelope-from uqs@roadrunner.spoerlein.net)
Received: (from uqs@localhost)
	by roadrunner.spoerlein.net (8.14.3/8.14.3/Submit) id n9SJO91e004590;
	Wed, 28 Oct 2009 20:24:09 +0100 (CET)
	(envelope-from uqs)
Message-Id: <200910281924.n9SJO91e004590@roadrunner.spoerlein.net>
Date: Wed, 28 Oct 2009 20:24:09 +0100 (CET)
From: Ulrich Spörlein <uqs@spoerlein.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: restore(8) increase to WARNS=2
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         140061
>Category:       bin
>Synopsis:       [patch] restore(8) increase to WARNS=2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 28 19:30:03 UTC 2009
>Closed-Date:    Fri Jan 29 10:21:22 UTC 2010
>Last-Modified:  Fri Nov 12 20:55:00 UTC 2010
>Originator:     Ulrich Spoerlein
>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:
Responsible-Changed-From-To: freebsd-bugs->jh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Thu Jan 28 15:55:20 UTC 2010 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140061 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/140061: commit references a PR
Date: Fri, 29 Jan 2010 10:01:18 +0000 (UTC)

 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 <bsd.prog.mk>
 
 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 <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 (*
  	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;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: jh 
State-Changed-When: Fri Jan 29 10:21:21 UTC 2010 
State-Changed-Why:  
Committed to head (r203155). Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140061 
>Unformatted:
