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
This commit is contained in:
Ulrich Spörlein 2012-10-21 12:01:19 +00:00
parent 6cf357bc6c
commit 3bbc4438c9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241807
8 changed files with 16 additions and 17 deletions

View File

@ -3,7 +3,6 @@
PROG= fsck
SRCS= fsck.c fsutil.c preen.c
WARNS?= 2
MAN= fsck.8
.include <bsd.prog.mk>

View File

@ -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 *spec, const char *mntpt,
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 *spec, const char *mntpt,
_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 char ***argvp, int *maxargcp)
}
const static char *
static const char *
getfslab(const char *str)
{
struct disklabel dl;

View File

@ -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 *));

View File

@ -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 *dev, const char *mntpt)
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;

View File

@ -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>

View File

@ -48,7 +48,7 @@ readboot(int dosfs, struct bootblock *boot)
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;
}

View File

@ -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

View File

@ -320,7 +320,7 @@ readfat(int fs, struct bootblock *boot, u_int no, struct fatEntry **fp)
/*
* Get type of reserved cluster
*/
char *
const char *
rsrvdcltype(cl_t cl)
{
if (cl == CLUST_FREE)