From uqs@spoerlein.net  Mon Oct 26 18:12:00 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 1041110656A8
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 26 Oct 2009 18:12:00 +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 9677C8FC20
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 26 Oct 2009 18:11:59 +0000 (UTC)
Received: from roadrunner.spoerlein.net (pD9E5C51D.dip.t-dialin.net [217.229.197.29])
	by acme.spoerlein.net (8.14.3/8.14.3) with ESMTP id n9QIBtLi060850
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 26 Oct 2009 19:11:57 +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 n9QIBeK0055079
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Mon, 26 Oct 2009 19:11:41 +0100 (CET)
	(envelope-from uqs@roadrunner.spoerlein.net)
Received: (from uqs@localhost)
	by roadrunner.spoerlein.net (8.14.3/8.14.3/Submit) id n9QIBeFn055078;
	Mon, 26 Oct 2009 19:11:40 +0100 (CET)
	(envelope-from uqs)
Message-Id: <200910261811.n9QIBeFn055078@roadrunner.spoerlein.net>
Date: Mon, 26 Oct 2009 19:11:40 +0100 (CET)
From: Ulrich Spoerlein <uqs@spoerlein.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: fsirand(8): increase to WARNS=2
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         139994
>Category:       bin
>Synopsis:       [patch] fsirand(8): increase to WARNS=2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    uqs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 26 18:20:00 UTC 2009
>Closed-Date:    Wed Jun 09 14:33:17 UTC 2010
>Last-Modified:  Wed Jun 09 14:33:17 UTC 2010
>Originator:     Ulrich Spoerlein
>Release:        FreeBSD 9.0-CURRENT i386
>Organization:
>Environment:
	
>Description:
Done by casting data types for printf(3) calls.
Higher warns are tricky due to signed/unsigned comparisons.

	
>How-To-Repeat:
	
>Fix:

	

--- fsirand.diff begins here ---
diff -r dabb79c85f13 -r c12ebdc97282 sbin/fsirand/Makefile
--- a/sbin/fsirand/Makefile	Fri Oct 23 10:34:06 2009 +0200
+++ b/sbin/fsirand/Makefile	Mon Oct 26 19:07:40 2009 +0100
@@ -2,7 +2,7 @@
 # $FreeBSD$
 
 PROG=	fsirand
-WARNS?=	0
+WARNS?=	2
 MAN=	fsirand.8
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
diff -r dabb79c85f13 -r c12ebdc97282 sbin/fsirand/fsirand.c
--- a/sbin/fsirand/fsirand.c	Fri Oct 23 10:34:06 2009 +0200
+++ b/sbin/fsirand/fsirand.c	Mon Oct 26 19:07:40 2009 +0100
@@ -47,6 +47,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -141,8 +142,8 @@
 	for (i = 0; sblock_try[i] != -1; i++) {
 		sblockloc = sblock_try[i];
 		if (lseek(devfd, sblockloc, SEEK_SET) == -1) {
-			warn("can't seek to superblock (%qd) on %s",
-			    sblockloc, device);
+			warn("can't seek to superblock (%jd) on %s",
+			    (intmax_t)sblockloc, device);
 			return (1);
 		}
 		if ((n = read(devfd, (void *)sblock, SBLOCKSIZE))!=SBLOCKSIZE) {
@@ -178,7 +179,7 @@
 	for (cg = 0; cg < sblock->fs_ncg; cg++) {
 		dblk = fsbtodb(sblock, cgsblock(sblock, cg));
 		if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-			warn("can't seek to %qd", (off_t)dblk * bsize);
+			warn("can't seek to %jd", (intmax_t)dblk * bsize);
 			return (1);
 		} else if ((n = write(devfd, (void *)sblock, SBLOCKSIZE)) != SBLOCKSIZE) {
 			warn("can't read backup superblock %d on %s: %s",
@@ -223,8 +224,8 @@
 		sblock->fs_id[1] = random();
 
 		if (lseek(devfd, sblockloc, SEEK_SET) == -1) {
-			warn("can't seek to superblock (%qd) on %s", sblockloc,
-			    device);
+			warn("can't seek to superblock (%jd) on %s",
+			    (intmax_t)sblockloc, device);
 			return (1);
 		}
 		if ((n = write(devfd, (void *)sblock, SBLOCKSIZE)) !=
@@ -241,7 +242,8 @@
 		if (!printonly) {
 			dblk = fsbtodb(sblock, cgsblock(sblock, cg));
 			if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-				warn("can't seek to %qd", (off_t)dblk * bsize);
+				warn("can't seek to %jd",
+				    (intmax_t)dblk * bsize);
 				return (1);
 			} else if ((n = write(devfd, (void *)sblock,
 			    SBLOCKSIZE)) != SBLOCKSIZE) {
@@ -255,7 +257,7 @@
 		/* Read in inodes, then print or randomize generation nums */
 		dblk = fsbtodb(sblock, ino_to_fsba(sblock, inumber));
 		if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-			warn("can't seek to %qd", (off_t)dblk * bsize);
+			warn("can't seek to %jd", (intmax_t)dblk * bsize);
 			return (1);
 		} else if ((n = read(devfd, inodebuf, ibufsize)) != ibufsize) {
 			warnx("can't read inodes: %s",
@@ -270,10 +272,10 @@
 				dp2 = &((struct ufs2_dinode *)inodebuf)[n];
 			if (inumber >= ROOTINO) {
 				if (printonly)
-					(void)printf("ino %d gen %qx\n",
+					(void)printf("ino %d gen %x\n",
 					    inumber,
 					    sblock->fs_magic == FS_UFS1_MAGIC ?
-					    (quad_t)dp1->di_gen : dp2->di_gen);
+					    dp1->di_gen : dp2->di_gen);
 				else if (sblock->fs_magic == FS_UFS1_MAGIC) 
 					dp1->di_gen = random(); 
 				else
@@ -284,8 +286,8 @@
 		/* Write out modified inodes */
 		if (!printonly) {
 			if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-				warn("can't seek to %qd",
-				    (off_t)dblk * bsize);
+				warn("can't seek to %jd",
+				    (intmax_t)dblk * bsize);
 				return (1);
 			} else if ((n = write(devfd, inodebuf, ibufsize)) !=
 				 ibufsize) {
--- fsirand.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->uqs 
Responsible-Changed-By: uqs 
Responsible-Changed-When: Thu Feb 4 08:22:12 UTC 2010 
Responsible-Changed-Why:  
Take my own PR. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/139994: commit references a PR
Date: Fri, 14 May 2010 14:27:02 +0000 (UTC)

 Author: uqs
 Date: Fri May 14 14:26:49 2010
 New Revision: 208074
 URL: http://svn.freebsd.org/changeset/base/208074
 
 Log:
   fsirand(8): make WARNS=3 clean
   
   - Drop bogus quad_t cast for di_gen, it is a 32bit type
   - Print di_gen with leading zeros, to get consistent output
     Before this change, amd64 would print:
   
     ino 18 gen 616ca2bd
     ino 19 gen ffffffff95c2a3ff
     ino 20 gen 25c3a3d5
     ino 21 gen 8dc1472
     ino 22 gen 3797056b
     ino 23 gen 1d47853a
     ino 24 gen ffffffff82d26995
   
     After the change
   
     ino 18 gen 616ca2bd
     ino 19 gen 95c2a3ff
     ino 20 gen 25c3a3d5
     ino 21 gen 08dc1472
     ino 22 gen 3797056b
     ino 23 gen 1d47853a
     ino 24 gen 82d26995
   
   PR:		bin/139994 (sort of)
   Reviewed by:	mckusick
 
 Modified:
   head/sbin/fsirand/Makefile
   head/sbin/fsirand/fsirand.c
 
 Modified: head/sbin/fsirand/Makefile
 ==============================================================================
 --- head/sbin/fsirand/Makefile	Fri May 14 13:48:11 2010	(r208073)
 +++ head/sbin/fsirand/Makefile	Fri May 14 14:26:49 2010	(r208074)
 @@ -2,8 +2,8 @@
  # $FreeBSD$
  
  PROG=	fsirand
 -WARNS?=	0
  MAN=	fsirand.8
 +WARNS?=	3
  DPADD=	${LIBUTIL}
  LDADD=	-lutil
  
 
 Modified: head/sbin/fsirand/fsirand.c
 ==============================================================================
 --- head/sbin/fsirand/fsirand.c	Fri May 14 13:48:11 2010	(r208073)
 +++ head/sbin/fsirand/fsirand.c	Fri May 14 14:26:49 2010	(r208074)
 @@ -47,6 +47,7 @@ static const char rcsid[] =
  #include <errno.h>
  #include <fcntl.h>
  #include <stdio.h>
 +#include <stdint.h>
  #include <stdlib.h>
  #include <string.h>
  #include <unistd.h>
 @@ -112,7 +113,7 @@ fsirand(char *device)
  	struct ufs1_dinode *dp1;
  	struct ufs2_dinode *dp2;
  	caddr_t inodebuf;
 -	size_t ibufsize;
 +	ssize_t ibufsize;
  	struct fs *sblock;
  	ino_t inumber, maxino;
  	ufs2_daddr_t sblockloc, dblk;
 @@ -135,14 +136,17 @@ fsirand(char *device)
  			bsize = label.d_secsize;
  	}
  
 +	dp1 = NULL;
 +	dp2 = NULL;
 +
  	/* Read in master superblock */
  	(void)memset(&sbuf, 0, sizeof(sbuf));
  	sblock = (struct fs *)&sbuf;
  	for (i = 0; sblock_try[i] != -1; i++) {
  		sblockloc = sblock_try[i];
  		if (lseek(devfd, sblockloc, SEEK_SET) == -1) {
 -			warn("can't seek to superblock (%qd) on %s",
 -			    sblockloc, device);
 +			warn("can't seek to superblock (%jd) on %s",
 +			    (intmax_t)sblockloc, device);
  			return (1);
  		}
  		if ((n = read(devfd, (void *)sblock, SBLOCKSIZE))!=SBLOCKSIZE) {
 @@ -154,7 +158,7 @@ fsirand(char *device)
  		     (sblock->fs_magic == FS_UFS2_MAGIC &&
  		      sblock->fs_sblockloc == sblock_try[i])) &&
  		    sblock->fs_bsize <= MAXBSIZE &&
 -		    sblock->fs_bsize >= sizeof(struct fs))
 +		    sblock->fs_bsize >= (ssize_t)sizeof(struct fs))
  			break;
  	}
  	if (sblock_try[i] == -1) {
 @@ -175,10 +179,10 @@ fsirand(char *device)
  
  	/* Make sure backup superblocks are sane. */
  	sblock = (struct fs *)&sbuftmp;
 -	for (cg = 0; cg < sblock->fs_ncg; cg++) {
 +	for (cg = 0; cg < (int)sblock->fs_ncg; cg++) {
  		dblk = fsbtodb(sblock, cgsblock(sblock, cg));
  		if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
 -			warn("can't seek to %qd", (off_t)dblk * bsize);
 +			warn("can't seek to %jd", (intmax_t)dblk * bsize);
  			return (1);
  		} else if ((n = write(devfd, (void *)sblock, SBLOCKSIZE)) != SBLOCKSIZE) {
  			warn("can't read backup superblock %d on %s: %s",
 @@ -211,7 +215,7 @@ fsirand(char *device)
  	if (printonly && (sblock->fs_id[0] || sblock->fs_id[1])) {
  		if (sblock->fs_id[0])
  			(void)printf("%s was randomized on %s", device,
 -			    ctime((const time_t *)&(sblock->fs_id[0])));
 +			    ctime((void *)&(sblock->fs_id[0])));
  		(void)printf("fsid: %x %x\n", sblock->fs_id[0],
  			    sblock->fs_id[1]);
  	}
 @@ -223,8 +227,8 @@ fsirand(char *device)
  		sblock->fs_id[1] = random();
  
  		if (lseek(devfd, sblockloc, SEEK_SET) == -1) {
 -			warn("can't seek to superblock (%qd) on %s", sblockloc,
 -			    device);
 +			warn("can't seek to superblock (%jd) on %s",
 +			    (intmax_t)sblockloc, device);
  			return (1);
  		}
  		if ((n = write(devfd, (void *)sblock, SBLOCKSIZE)) !=
 @@ -236,12 +240,13 @@ fsirand(char *device)
  	}
  
  	/* For each cylinder group, randomize inodes and update backup sblock */
 -	for (cg = 0, inumber = 0; cg < sblock->fs_ncg; cg++) {
 +	for (cg = 0, inumber = 0; cg < (int)sblock->fs_ncg; cg++) {
  		/* Update superblock if appropriate */
  		if (!printonly) {
  			dblk = fsbtodb(sblock, cgsblock(sblock, cg));
  			if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
 -				warn("can't seek to %qd", (off_t)dblk * bsize);
 +				warn("can't seek to %jd",
 +				    (intmax_t)dblk * bsize);
  				return (1);
  			} else if ((n = write(devfd, (void *)sblock,
  			    SBLOCKSIZE)) != SBLOCKSIZE) {
 @@ -255,7 +260,7 @@ fsirand(char *device)
  		/* Read in inodes, then print or randomize generation nums */
  		dblk = fsbtodb(sblock, ino_to_fsba(sblock, inumber));
  		if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
 -			warn("can't seek to %qd", (off_t)dblk * bsize);
 +			warn("can't seek to %jd", (intmax_t)dblk * bsize);
  			return (1);
  		} else if ((n = read(devfd, inodebuf, ibufsize)) != ibufsize) {
  			warnx("can't read inodes: %s",
 @@ -263,17 +268,17 @@ fsirand(char *device)
  			return (1);
  		}
  
 -		for (n = 0; n < sblock->fs_ipg; n++, inumber++) {
 +		for (n = 0; n < (int)sblock->fs_ipg; n++, inumber++) {
  			if (sblock->fs_magic == FS_UFS1_MAGIC)
  				dp1 = &((struct ufs1_dinode *)inodebuf)[n];
  			else
  				dp2 = &((struct ufs2_dinode *)inodebuf)[n];
  			if (inumber >= ROOTINO) {
  				if (printonly)
 -					(void)printf("ino %d gen %qx\n",
 +					(void)printf("ino %d gen %08x\n",
  					    inumber,
  					    sblock->fs_magic == FS_UFS1_MAGIC ?
 -					    (quad_t)dp1->di_gen : dp2->di_gen);
 +					    dp1->di_gen : dp2->di_gen);
  				else if (sblock->fs_magic == FS_UFS1_MAGIC) 
  					dp1->di_gen = random(); 
  				else
 @@ -284,8 +289,8 @@ fsirand(char *device)
  		/* Write out modified inodes */
  		if (!printonly) {
  			if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
 -				warn("can't seek to %qd",
 -				    (off_t)dblk * bsize);
 +				warn("can't seek to %jd",
 +				    (intmax_t)dblk * bsize);
  				return (1);
  			} else if ((n = write(devfd, inodebuf, ibufsize)) !=
  				 ibufsize) {
 _______________________________________________
 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->patched 
State-Changed-By: uqs 
State-Changed-When: Fri May 14 14:50:40 UTC 2010 
State-Changed-Why:  
Patch has been committed, keep PR open for MFC reminder only 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139994 
State-Changed-From-To: patched->closed 
State-Changed-By: uqs 
State-Changed-When: Wed Jun 9 14:33:16 UTC 2010 
State-Changed-Why:  
Committed, with minor changes. Thanks! 

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