Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Oct 2012 12:01:19 +0000 (UTC)
From:      Ulrich Spoerlein <uqs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241807 - in head/sbin: fsck fsck_msdosfs
Message-ID:  <201210211201.q9LC1JiD068601@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: uqs
Date: Sun Oct 21 12:01:19 2012
New Revision: 241807
URL: http://svn.freebsd.org/changeset/base/241807

Log:
  Make fsck and fsck_msdosfs WARNS=6 clean
  
  - sprinkle const
  - add volatile qualifier to avoid vfork clobbering
  
  Inspired by:	NetBSD
  PR:		bin/139802
  Reviewed by:	ed

Modified:
  head/sbin/fsck/Makefile
  head/sbin/fsck/fsck.c
  head/sbin/fsck/fsutil.h
  head/sbin/fsck/preen.c
  head/sbin/fsck_msdosfs/Makefile
  head/sbin/fsck_msdosfs/boot.c
  head/sbin/fsck_msdosfs/ext.h
  head/sbin/fsck_msdosfs/fat.c

Modified: head/sbin/fsck/Makefile
==============================================================================
--- head/sbin/fsck/Makefile	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck/Makefile	Sun Oct 21 12:01:19 2012	(r241807)
@@ -3,7 +3,6 @@
 
 PROG=	fsck
 SRCS=	fsck.c fsutil.c preen.c
-WARNS?=	2
 MAN=	fsck.8
 
 .include <bsd.prog.mk>

Modified: head/sbin/fsck/fsck.c
==============================================================================
--- head/sbin/fsck/fsck.c	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck/fsck.c	Sun Oct 21 12:01:19 2012	(r241807)
@@ -73,14 +73,14 @@ static char *options = NULL;
 static int flags = 0;
 static int forceflag = 0;
 
-static int checkfs(const char *, const char *, const char *, char *, pid_t *);
+static int checkfs(const char *, const char *, const char *, const char *, pid_t *);
 static int selected(const char *);
 static void addoption(char *);
 static const char *getoptions(const char *);
 static void addentry(struct fstypelist *, const char *, const char *);
 static void maketypelist(char *);
 static void catopt(char **, const char *);
-static void mangle(char *, int *, const char ***, int *);
+static void mangle(char *, int *, const char ** volatile *, int *);
 static const char *getfslab(const char *);
 static void usage(void) __dead2;
 static int isok(struct fstab *);
@@ -187,6 +187,7 @@ main(int argc, char *argv[])
 		char device[MAXPATHLEN];
 		struct statfs *mntp;
 
+		mntpt = NULL;
 		spec = *argv;
 		cp = strrchr(spec, '/');
 		if (cp == 0) {
@@ -285,9 +286,9 @@ isok(struct fstab *fs)
 
 static int
 checkfs(const char *pvfstype, const char *spec, const char *mntpt,
-    char *auxopt, pid_t *pidp)
+    const char *auxopt, pid_t *pidp)
 {
-	const char **argv;
+	const char ** volatile argv;
 	pid_t pid;
 	int argc, i, status, maxargc;
 	char *optbuf, execbase[MAXPATHLEN];
@@ -312,7 +313,7 @@ checkfs(const char *pvfstype, const char
 	vfstype = strdup(pvfstype);
 	if (vfstype == NULL)
 		perr("strdup(pvfstype)");
-	for (i = 0; i < strlen(vfstype); i++) {
+	for (i = 0; i < (int)strlen(vfstype); i++) {
 		vfstype[i] = tolower(vfstype[i]);
 		if (vfstype[i] == ' ')
 			vfstype[i] = '_';
@@ -361,7 +362,7 @@ checkfs(const char *pvfstype, const char
 			_exit(0);
 
 		/* Go find an executable. */
-		execvP(execbase, _PATH_SYSPATH, (char * const *)argv);
+		execvP(execbase, _PATH_SYSPATH, __DECONST(char * const *, argv));
 		if (spec)
 			warn("exec %s for %s in %s", execbase, spec, _PATH_SYSPATH);
 		else
@@ -498,7 +499,7 @@ catopt(char **sp, const char *o)
 
 
 static void
-mangle(char *opts, int *argcp, const char ***argvp, int *maxargcp)
+mangle(char *opts, int *argcp, const char ** volatile *argvp, int *maxargcp)
 {
 	char *p, *s;
 	int argc, maxargc;
@@ -535,7 +536,7 @@ mangle(char *opts, int *argcp, const cha
 }
 
 
-const static char *
+static const char *
 getfslab(const char *str)
 {
 	struct disklabel dl;

Modified: head/sbin/fsck/fsutil.h
==============================================================================
--- head/sbin/fsck/fsutil.h	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck/fsutil.h	Sun Oct 21 12:01:19 2012	(r241807)
@@ -47,4 +47,4 @@ char *estrdup(const char *);
 
 struct fstab;
 int checkfstab(int, int (*)(struct fstab *), 
-    int (*) (const char *, const char *, const char *, char *, pid_t *));
+    int (*) (const char *, const char *, const char *, const char *, pid_t *));

Modified: head/sbin/fsck/preen.c
==============================================================================
--- head/sbin/fsck/preen.c	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck/preen.c	Sun Oct 21 12:01:19 2012	(r241807)
@@ -78,12 +78,12 @@ static int nrun = 0, ndisks = 0;
 static struct diskentry *finddisk(const char *);
 static void addpart(const char *, const char *, const char *);
 static int startdisk(struct diskentry *, 
-    int (*)(const char *, const char *, const char *, char *, pid_t *));
+    int (*)(const char *, const char *, const char *, const char *, pid_t *));
 static void printpart(void);
 
 int
 checkfstab(int flags, int (*docheck)(struct fstab *), 
-    int (*checkit)(const char *, const char *, const char *, char *, pid_t *))
+    int (*checkit)(const char *, const char *, const char *, const char *, pid_t *))
 {
 	struct fstab *fs;
 	struct diskentry *d, *nextdisk;
@@ -317,7 +317,7 @@ addpart(const char *type, const char *de
 
 static int
 startdisk(struct diskentry *d, int (*checkit)(const char *, const char *,
-    const char *, char *, pid_t *))
+    const char *, const char *, pid_t *))
 {
 	struct partentry *p = TAILQ_FIRST(&d->d_part);
 	int rv;

Modified: head/sbin/fsck_msdosfs/Makefile
==============================================================================
--- head/sbin/fsck_msdosfs/Makefile	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck_msdosfs/Makefile	Sun Oct 21 12:01:19 2012	(r241807)
@@ -9,6 +9,5 @@ MAN=	fsck_msdosfs.8
 SRCS=	main.c check.c boot.c fat.c dir.c fsutil.c
 
 CFLAGS+= -I${FSCK}
-WARNS?=	2
 
 .include <bsd.prog.mk>

Modified: head/sbin/fsck_msdosfs/boot.c
==============================================================================
--- head/sbin/fsck_msdosfs/boot.c	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck_msdosfs/boot.c	Sun Oct 21 12:01:19 2012	(r241807)
@@ -48,7 +48,7 @@ readboot(int dosfs, struct bootblock *bo
 	int ret = FSOK;
 	int i;
 	
-	if (read(dosfs, block, sizeof block) != sizeof block) {
+	if ((size_t)read(dosfs, block, sizeof block) != sizeof block) {
 		perr("could not read boot block");
 		return FSFATAL;
 	}

Modified: head/sbin/fsck_msdosfs/ext.h
==============================================================================
--- head/sbin/fsck_msdosfs/ext.h	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck_msdosfs/ext.h	Sun Oct 21 12:01:19 2012	(r241807)
@@ -133,7 +133,7 @@ void finishlf(void);
 /*
  * Return the type of a reserved cluster as text
  */
-char *rsrvdcltype(cl_t);
+const char *rsrvdcltype(cl_t);
 
 /*
  * Clear a cluster chain in a FAT

Modified: head/sbin/fsck_msdosfs/fat.c
==============================================================================
--- head/sbin/fsck_msdosfs/fat.c	Sun Oct 21 12:01:11 2012	(r241806)
+++ head/sbin/fsck_msdosfs/fat.c	Sun Oct 21 12:01:19 2012	(r241807)
@@ -320,7 +320,7 @@ readfat(int fs, struct bootblock *boot, 
 /*
  * Get type of reserved cluster
  */
-char *
+const char *
 rsrvdcltype(cl_t cl)
 {
 	if (cl == CLUST_FREE)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210211201.q9LC1JiD068601>