DragonFly BSD
DragonFly submit List (threaded) for 2005-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

A few WARNS6 cleanups


From: Peter Schuller <peter.schuller@xxxxxxxxxxxx>
Date: Sun, 2 Jan 2005 02:33:26 +0100

split/xargs: already WARNS6 compliant; patches only bumps WARNS

iostat: minor changes required

newfs: minor changes required to supress warnings; but there seems to be
a lot of mixing of signed/unsigned types in general and I have not
attempted to actually fix the underlying issues (which I suspect are not
specific to newfs). note: patch also modifies sbin/mount/mntopts.h.

-- 
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@xxxxxxxxxxxx>'
Key retrieval: Send an E-Mail to getpgpkey@xxxxxxxxx
E-Mail: peter.schuller@xxxxxxxxxxxx Web: http://www.scode.org

--- usr.bin/split/Makefile.orig	2004-12-31 17:30:11.000000000 +0000
+++ usr.bin/split/Makefile	2004-12-31 17:29:47.000000000 +0000
@@ -3,5 +3,6 @@
 # $DragonFly: src/usr.bin/split/Makefile,v 1.2 2003/06/17 04:29:31 dillon Exp $
 
 PROG=	split
+WARNS?= 6
 
 .include <bsd.prog.mk>
--- usr.bin/xargs/Makefile.orig	2004-12-31 17:28:35.000000000 +0000
+++ usr.bin/xargs/Makefile	2004-12-31 17:27:59.000000000 +0000
@@ -4,7 +4,7 @@
 
 PROG=	xargs
 SRCS=	xargs.c strnsubst.c
-WARNS?=	4
+WARNS?=	6
 
 .if defined(BOOTSTRAPPING)
 CFLAGS+=-DBOOTSTRAPPING
--- usr.sbin/iostat/Makefile.orig	2005-01-01 17:01:26.000000000 +0000
+++ usr.sbin/iostat/Makefile	2005-01-01 17:01:26.000000000 +0000
@@ -7,5 +7,6 @@
 CFLAGS+=-I${.CURDIR}/../../sys
 DPADD=	${LIBDEVSTAT} ${LIBKINFO}
 LDADD=	-ldevstat -lkinfo
+WARNS?= 6
 
 .include <bsd.prog.mk>
--- usr.sbin/iostat/iostat.c.orig	2005-01-01 17:01:26.000000000 +0000
+++ usr.sbin/iostat/iostat.c	2005-01-01 17:01:26.000000000 +0000
@@ -126,7 +126,8 @@
 
 /* local function declarations */
 static void usage(void);
-static void phdr(int signo);
+static void sighandler(int signo);
+static void phdr(void);
 static void devstats(int perf_select);
 static void cpustats(void);
 
@@ -148,13 +149,11 @@
 main(int argc, char **argv)
 {
 	int c;
-	int i;
 	int tflag = 0, hflag = 0, cflag = 0, wflag = 0, nflag = 0;
 	int count = 0, waittime = 0;
 	struct devstat_match *matches;
 	int num_matches = 0;
-        char errbuf[_POSIX2_LINE_MAX];
-	int hz, stathz;
+	int hz;
 	int headercount;
 	long generation;
 	int num_devices_specified;
@@ -361,14 +360,13 @@
 	 * If the user stops the program (control-Z) and then resumes it,
 	 * print out the header again.
 	 */
-	signal(SIGCONT, phdr);
+	signal(SIGCONT, sighandler);
 
 	for (headercount = 1;;) {
 		struct devinfo *tmp_dinfo;
-		long tmp;
 
 		if (!--headercount) {
-			phdr(0);
+			phdr();
 			headercount = 20;
 		}
 		if (kinfo_get_tty_tk_nin(&tk_nin))
@@ -412,7 +410,7 @@
 				errx(1, "%s", devstat_errbuf);
 				break;
 			case 1:
-				phdr(0);
+				phdr();
 				headercount = 20;
 				break;
 			default:
@@ -443,7 +441,7 @@
 				errx(1,"%s", devstat_errbuf);
 				break;
 			case 1:
-				phdr(0);
+				phdr();
 				headercount = 20;
 				break;
 			default:
@@ -488,7 +486,18 @@
 }
 
 static void
-phdr(int signo)
+sighandler(int signo)
+{
+	if(signo == SIGCONT) {
+		phdr();
+	} else {
+		fprintf(stderr, "BUG: sighandler does not know about sig %d\n",
+			signo);
+	}
+}
+
+static void
+phdr()
 {
 	int i;
 	int printed;
@@ -627,7 +636,6 @@
 static void
 cpustats(void)
 {
-	int state;
 
 	if (cp_time_total == 0.0)
 		cp_time_total = 1.0;
--- sbin/newfs/Makefile.orig	2005-01-01 14:58:24.000000000 +0000
+++ sbin/newfs/Makefile	2004-12-31 17:30:46.000000000 +0000
@@ -5,6 +5,7 @@
 PROG=	newfs
 SRCS=	getmntopts.c newfs.c mkfs.c fscopy.c
 MAN=	newfs.8
+WARNS?= 6
 
 MOUNT=	${.CURDIR}/../mount
 CFLAGS+=-DMFS -DFSIRAND -I${MOUNT}
--- sbin/newfs/fscopy.c.orig	2005-01-01 14:58:53.000000000 +0000
+++ sbin/newfs/fscopy.c	2005-01-01 17:00:00.000000000 +0000
@@ -51,6 +51,8 @@
     char		fs_Name[4];
 };
 
+static char empty_string[] = "";
+
 static
 fsnode_t
 fsmknode(const char *path)
@@ -72,7 +74,7 @@
     return(node);
 }
 
-fsnode_t
+static fsnode_t
 fsgethlink(fsnode_t hlinks, fsnode_t node)
 {
     fsnode_t scan;
@@ -87,7 +89,7 @@
     return(NULL);
 }
 
-char *
+static char *
 fshardpath(fsnode_t hlink, fsnode_t node)
 {
     fsnode_t scan;
@@ -221,7 +223,7 @@
 		    node->fs_Data[n] = 0;
 		}
 	    } else if (n == 0) {
-		node->fs_Data = "";
+		node->fs_Data = empty_string;
 		node->fs_Bytes = 0;
 	    } else {
 		fprintf(stderr, "Unable to read link: %s\n", path);
--- sbin/newfs/mkfs.c.orig	2005-01-01 14:58:35.000000000 +0000
+++ sbin/newfs/mkfs.c	2005-01-01 16:45:13.000000000 +0000
@@ -45,7 +45,7 @@
 extern char * getenv(char *);
 #endif
 
-#ifdef FSIRAND
+#if defined(FSIRAND) && defined(STANDALONE)
 extern long random(void);
 extern void srandomdev(void);
 #endif
@@ -128,9 +128,9 @@
 #ifdef FSIRAND
 int     randinit;
 #endif
-daddr_t	alloc();
-long	calcipg();
-static int charsperline();
+daddr_t	alloc(int size, int mode);
+long	calcipg(long cylspg, long bpcg, off_t *usedbp);
+static int charsperline(void);
 void clrblock(struct fs *, unsigned char *, int);
 void fsinit(time_t);
 void initcg(int, time_t);
@@ -152,6 +152,9 @@
 caddr_t realloc(char *, u_long);
 #endif
 
+void started(int signo);
+void parentready(int signo);
+
 int mfs_ppid = 0;
 int parentready_signalled;
 
@@ -159,7 +162,7 @@
 mkfs(struct partition *pp, char *fsys, int fi, int fo, const char *mfscopy)
 {
 	register long i, mincpc, mincpg, inospercg;
-	long cylno, rpos, blk, j, warn = 0;
+	long cylno, rpos, blk, j, emitwarn = 0;
 	long used, mincpgcnt, bpcg;
 	off_t usedb;
 	long mapcramped, inodecramped;
@@ -167,8 +170,6 @@
 	int status, fd;
 	time_t utime;
 	quad_t sizepb;
-	void started();
-	void parentready();
 	int width;
 	char tmpbuf[100];	/* XXX this will break in about 2,500 years */
 
@@ -213,11 +214,13 @@
 			fd = open(filename,O_RDWR|O_TRUNC|O_CREAT,0644);
 			if(fd < 0)
 				err(12, "%s", filename);
-			for(l=0;l< fssize * sectorsize;l += l1) {
+			for(l = 0;
+			    l < (unsigned long)fssize * (unsigned long)sectorsize;
+			    l += l1) {
 				l1 = fssize * sectorsize;
 				if (BUFSIZ < l1)
 					l1 = BUFSIZ;
-				if (l1 != write(fd,buf,l1))
+				if (l1 != (unsigned long)write(fd,buf,l1))
 					err(12, "%s", filename);
 			}
 			membase = mmap(
@@ -234,7 +237,8 @@
 #ifndef STANDALONE
 			get_memleft();
 #endif
-			if (fssize * sectorsize > (memleft - 131072))
+			if ((u_long)fssize * (u_long)sectorsize >
+			    (memleft - 131072))
 				fssize = (memleft - 131072) / sectorsize;
 			if ((membase = malloc(fssize * sectorsize)) == NULL)
 				errx(13, "malloc failed");
@@ -375,7 +379,7 @@
 	if (maxcontig > 1)
 		sblock.fs_contigsumsize = MIN(maxcontig, FS_MAXCONTIG);
 	mapcramped = 0;
-	while (CGSIZE(&sblock) > sblock.fs_bsize) {
+	while (CGSIZE(&sblock) > (uint32_t)sblock.fs_bsize) {
 		mapcramped = 1;
 		if (sblock.fs_bsize < MAXBSIZE) {
 			sblock.fs_bsize <<= 1;
@@ -422,7 +426,7 @@
 		sblock.fs_fragshift -= 1;
 		mincpc >>= 1;
 		sblock.fs_cpg = roundup(mincpgcnt, mincpc);
-		if (CGSIZE(&sblock) > sblock.fs_bsize) {
+		if (CGSIZE(&sblock) > (uint32_t)sblock.fs_bsize) {
 			sblock.fs_bsize <<= 1;
 			break;
 		}
@@ -478,7 +482,7 @@
 	/*
 	 * Must ensure there is enough space to hold block map.
 	 */
-	while (CGSIZE(&sblock) > sblock.fs_bsize) {
+	while (CGSIZE(&sblock) > (uint32_t)sblock.fs_bsize) {
 		mapcramped = 1;
 		sblock.fs_cpg -= mincpc;
 		sblock.fs_ipg = calcipg(sblock.fs_cpg, bpcg, &usedb);
@@ -518,7 +522,7 @@
 	sblock.fs_ncyl = fssize * NSPF(&sblock) / sblock.fs_spc;
 	if (fssize * NSPF(&sblock) > sblock.fs_ncyl * sblock.fs_spc) {
 		sblock.fs_ncyl++;
-		warn = 1;
+		emitwarn = 1;
 	}
 	if (sblock.fs_ncyl < 1) {
 		printf("file systems must have at least one cylinder\n");
@@ -630,9 +634,9 @@
 		sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg;
 		sblock.fs_size = fssize = sblock.fs_ncyl * sblock.fs_spc /
 		    NSPF(&sblock);
-		warn = 0;
+		emitwarn = 0;
 	}
-	if (warn && !mfs) {
+	if (emitwarn && !mfs) {
 		printf("Warning: %d sector(s) in last cylinder unallocated\n",
 		    sblock.fs_spc -
 		    (fssize * NSPF(&sblock) - (sblock.fs_ncyl - 1)
@@ -770,7 +774,7 @@
 	long i;
 	register struct csum *cs;
 #ifdef FSIRAND
-	long j;
+	uint32_t j;
 #endif
 
 	/*
@@ -824,14 +828,17 @@
 	}
 	acg.cg_cs.cs_nifree += sblock.fs_ipg;
 	if (cylno == 0)
-		for (i = 0; i < ROOTINO; i++) {
+		for (i = 0; i < (long)ROOTINO; i++) {
 			setbit(cg_inosused(&acg), i);
 			acg.cg_cs.cs_nifree--;
 		}
 	for (i = 0; i < sblock.fs_ipg / INOPF(&sblock); i += sblock.fs_frag) {
 #ifdef FSIRAND
-		for (j = 0; j < sblock.fs_bsize / sizeof(struct dinode); j++)
+		for (j = 0;
+		     j < sblock.fs_bsize / sizeof(struct dinode);
+		     j++) {
 			zino[j].di_gen = random();
+		}
 #endif
 		wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
 		    sblock.fs_bsize, (char *)zino);
@@ -1094,7 +1101,7 @@
  * Calculate number of inodes per group.
  */
 long
-calcipg(long cpg, long bpcg, off_t *usedbp)
+calcipg(long cylspg, long bpcg, off_t *usedbp)
 {
 	int i;
 	long ipg, new_ipg, ncg, ncyl;
@@ -1105,7 +1112,7 @@
 	 * Note that fssize is still in sectors, not filesystem blocks.
 	 */
 	ncyl = howmany(fssize, (u_int)secpercyl);
-	ncg = howmany(ncyl, cpg);
+	ncg = howmany(ncyl, cylspg);
 	/*
 	 * Iterate a few times to allow for ipg depending on itself.
 	 */
@@ -1113,8 +1120,8 @@
 	for (i = 0; i < 10; i++) {
 		usedb = (sblock.fs_iblkno + ipg / INOPF(&sblock))
 			* NSPF(&sblock) * (off_t)sectorsize;
-		new_ipg = (cpg * (quad_t)bpcg - usedb) / density * fssize
-			  / ncg / secpercyl / cpg;
+		new_ipg = (cylspg * (quad_t)bpcg - usedb) / density * fssize
+			  / ncg / secpercyl / cylspg;
 		new_ipg = roundup(new_ipg, INOPB(&sblock));
 		if (new_ipg == ipg)
 			break;
@@ -1130,7 +1137,7 @@
 void
 iput(register struct dinode *ip, register ino_t ino)
 {
-	struct dinode buf[MAXINOPB];
+	struct dinode inobuf[MAXINOPB];
 	daddr_t d;
 	int c;
 
@@ -1150,14 +1157,14 @@
 	    (char *)&acg);
 	sblock.fs_cstotal.cs_nifree--;
 	fscs[0].cs_nifree--;
-	if (ino >= sblock.fs_ipg * sblock.fs_ncg) {
+	if (ino >= (uint32_t)sblock.fs_ipg * (uint32_t)sblock.fs_ncg) {
 		printf("fsinit: inode value out of range (%d).\n", ino);
 		exit(32);
 	}
 	d = fsbtodb(&sblock, ino_to_fsba(&sblock, ino));
-	rdfs(d, sblock.fs_bsize, (char *)buf);
-	buf[ino_to_fsbo(&sblock, ino)] = *ip;
-	wtfs(d, sblock.fs_bsize, (char *)buf);
+	rdfs(d, sblock.fs_bsize, (char *)inobuf);
+	inobuf[ino_to_fsbo(&sblock, ino)] = *ip;
+	wtfs(d, sblock.fs_bsize, (char *)inobuf);
 }
 
 /*
@@ -1167,8 +1174,9 @@
  * parent forked the child otherwise).
  */
 void
-parentready(void)
+parentready(int signo)
 {
+	signo = SIGUSR1; /* Supress unused param. warning */
   	parentready_signalled = 1;
 }
 
@@ -1178,10 +1186,11 @@
  * We have to wait until the mount has actually completed!
  */
 void
-started(void)
+started(int signo)
 {
 	int retry = 100;	/* 10 seconds, 100ms */
 
+	signo = SIGUSR1; /* Supress unused param. warning */
 	while (mfs_ppid && retry) {
 		struct stat st;
 
@@ -1306,7 +1315,7 @@
 
 	pgsz = getpagesize() - 1;
 	dstart = ((u_long)&etext) &~ pgsz;
-	freestart = ((u_long)(sbrk(0) + pgsz) &~ pgsz);
+	freestart = ((u_long)((char*)sbrk(0) + pgsz) &~ pgsz);
 	if (getrlimit(RLIMIT_DATA, &rlp) < 0)
 		warn("getrlimit");
 	memused = freestart - dstart;
--- sbin/newfs/newfs.c.orig	2005-01-01 14:58:31.000000000 +0000
+++ sbin/newfs/newfs.c	2005-01-01 16:12:56.000000000 +0000
@@ -77,7 +77,7 @@
 struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_ASYNC,
-	{ NULL },
+	MOPT_NULL,
 };
 
 void	fatal(const char *fmt, ...);
@@ -215,12 +215,13 @@
 	register struct partition *pp;
 	register struct disklabel *lp;
 	struct disklabel mfsfakelabel;
-	struct disklabel *getdisklabel();
+	//CLEANUP	struct disklabel *getdisklabel();
 	struct partition oldpartition;
 	struct stat st;
 	struct statfs *mp;
 	int fsi = 0, fso, len, n, vflag;
-	char *cp = NULL, *s1, *s2, *special, *opstring;
+	char *cp = NULL, *s1, *s2, *special;
+	const char *opstring;
 #ifdef MFS
 	struct vfsconf vfc;
 	int error;
@@ -485,7 +486,7 @@
 havelabel:
 	if (fssize == 0)
 		fssize = pp->p_size;
-	if (fssize > pp->p_size && !mfs)
+	if ((uint32_t)fssize > pp->p_size && !mfs)
 	       fatal("%s: maximum file system size on the `%c' partition is %d",
 			argv[0], *cp, pp->p_size);
 	if (rpm == 0) {
@@ -560,7 +561,7 @@
 	 * case (4096 sectors per cylinder) is intended to disagree
 	 * with the disklabel.
 	 */
-	if (t_or_u_flag && secpercyl != lp->d_secpercyl)
+	if (t_or_u_flag && (uint32_t)secpercyl != lp->d_secpercyl)
 		fprintf(stderr, "%s (%d) %s (%lu)\n",
 			"Warning: calculated sectors per cylinder", secpercyl,
 			"disagrees with disk label", (u_long)lp->d_secpercyl);
@@ -665,6 +666,7 @@
 static void
 mfsintr(int signo)
 {
+	signo = SIGINT; /* Supress unused param. warning */
 	if (filename)
 		munmap(membase, fssize * sectorsize);
 	remove(mfsdevname);
@@ -686,7 +688,7 @@
 	if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
 #ifdef COMPAT
 		if (disktype) {
-			struct disklabel *lp, *getdiskbyname();
+			struct disklabel *lp;
 
 			unlabeled++;
 			lp = getdiskbyname(disktype);
--- sbin/mount/mntopts.h.orig	2005-01-01 15:36:52.000000000 +0000
+++ sbin/mount/mntopts.h	2005-01-01 15:57:35.000000000 +0000
@@ -64,6 +64,9 @@
 #define MOPT_RO			{ "ro",		0, MNT_RDONLY, 0 }
 #define MOPT_RW			{ "rw",		1, MNT_RDONLY, 0 }
 
+/* NULL option; used to terminate arrays of options */
+#define MOPT_NULL		{ NULL,         0, 0, 0 }
+
 /* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
 #define MOPT_AUTO		{ "auto",	0, 0, 0 }
 


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]