Fix a large number of -Wall, -Wformat and -W compiler warnings.

These were mainly missing casts or wrong format strings in printf
statements, but there were also missing includes, unused variables,
functions and arguments.

The choice of `long' vs `int' still seems almost random in a lot
of places though.
This commit is contained in:
Ian Dowse 2001-11-17 23:48:21 +00:00
parent cfbfffc8e9
commit bf58d635ba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=86514
11 changed files with 50 additions and 59 deletions

View File

@ -373,7 +373,7 @@ adjust(idesc, lcnt)
cmd.value = idesc->id_number;
cmd.size = -lcnt;
if (debug)
printf("adjrefcnt ino %d amt %d\n",
printf("adjrefcnt ino %ld amt %ld\n",
(long)cmd.value, cmd.size);
if (sysctl(adjrefcnt, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
@ -545,7 +545,7 @@ linkup(orphan, parentdir, name)
dp->di_nlink++;
inodirty();
inoinfo(lfdir)->ino_linkcnt++;
pwarn("DIR I=%lu CONNECTED. ", orphan);
pwarn("DIR I=%lu CONNECTED. ", (u_long)orphan);
if (parentdir != (ino_t)-1) {
printf("PARENT WAS I=%lu\n", (u_long)parentdir);
/*

View File

@ -102,15 +102,17 @@ struct bufarea cgblk; /* cylinder group blocks */
struct bufarea *pdirbp; /* current directory contents */
struct bufarea *pbp; /* current inode block */
#define dirty(bp) \
#define dirty(bp) do { \
if (fswritefd < 0) \
pfatal("SETTING DIRTY FLAG IN READ_ONLY MODE\n"); \
else \
(bp)->b_dirty = 1
#define initbarea(bp) \
(bp)->b_dirty = 1; \
} while (0)
#define initbarea(bp) do { \
(bp)->b_dirty = 0; \
(bp)->b_bno = (ufs_daddr_t)-1; \
(bp)->b_flags = 0;
(bp)->b_flags = 0; \
} while (0)
#define sbdirty() dirty(&sblk)
#define cgdirty() dirty(&cgblk)
@ -319,4 +321,3 @@ void rwerror __P((char *mesg, ufs_daddr_t blk));
void sblock_init __P((void));
void setinodebuf __P((ino_t));
int setup __P((char *dev));
void voidquit __P((int));

View File

@ -41,6 +41,7 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
#include <ufs/ufs/dinode.h>
@ -268,7 +269,7 @@ rwerror(mesg, blk)
exit(EEXIT);
if (preen == 0)
printf("\n");
pfatal("CANNOT %s: %ld", mesg, blk);
pfatal("CANNOT %s: %ld", mesg, (long)blk);
if (reply("CONTINUE") == 0)
exit(EEXIT);
}
@ -564,20 +565,6 @@ catchquit(sig)
(void)signal(SIGQUIT, SIG_DFL);
}
/*
* Ignore a single quit signal; wait and flush just in case.
* Used by child processes in preen.
*/
void
voidquit(sig)
int sig;
{
sleep(1);
(void)signal(SIGQUIT, SIG_IGN);
(void)signal(SIGQUIT, SIG_DFL);
}
/*
* determine whether an inode should be fixed.
*/

View File

@ -254,8 +254,8 @@ chkrange(blk, cnt)
if (cnt > sblock.fs_frag ||
fragnum(&sblock, blk) + cnt > sblock.fs_frag) {
if (debug)
printf("bad size: blk %ld, offset %ld, size %ld\n",
blk, fragnum(&sblock, blk), cnt);
printf("bad size: blk %ld, offset %i, size %d\n",
(long)blk, (int)fragnum(&sblock, blk), cnt);
return (1);
}
c = dtog(&sblock, blk);
@ -493,7 +493,7 @@ clri(idesc, type, flag)
cmd.value = idesc->id_number;
cmd.size = -dp->di_nlink;
if (debug)
printf("adjrefcnt ino %d amt %d\n",
printf("adjrefcnt ino %ld amt %ld\n",
(long)cmd.value, cmd.size);
if (sysctl(adjrefcnt, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
@ -580,7 +580,7 @@ blkerror(ino, type, blk)
ufs_daddr_t blk;
{
pfatal("%ld %s I=%lu", blk, type, ino);
pfatal("%ld %s I=%lu", (long)blk, type, (u_long)ino);
printf("\n");
switch (inoinfo(ino)->ino_state) {

View File

@ -51,6 +51,7 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/mount.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/ufsmount.h>
@ -60,14 +61,13 @@ static const char rcsid[] =
#include <errno.h>
#include <fstab.h>
#include <paths.h>
#include <string.h>
#include "fsck.h"
static void usage __P((void));
static int argtoi __P((int flag, char *req, char *str, int base));
static int docheck __P((struct fstab *fsp));
static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
int child));
static int checkfilesys __P((char *filesys));
static struct statfs *getmntpt __P((const char *));
int main __P((int argc, char *argv[]));
@ -156,7 +156,7 @@ main(argc, argv)
(void)setrlimit(RLIMIT_DATA, &rlimit);
}
while (argc-- > 0)
(void)checkfilesys(*argv++, 0, 0L, 0);
(void)checkfilesys(*argv++);
if (returntosingle)
ret = 2;
@ -183,10 +183,8 @@ argtoi(flag, req, str, base)
*/
/* ARGSUSED */
static int
checkfilesys(filesys, mntpt, auxdata, child)
char *filesys, *mntpt;
long auxdata;
int child;
checkfilesys(filesys)
char *filesys;
{
ufs_daddr_t n_ffree, n_bfree;
struct ufs_args args;
@ -197,8 +195,6 @@ checkfilesys(filesys, mntpt, auxdata, child)
ufs_daddr_t files;
int cylno, size;
if (preen && child)
(void)signal(SIGQUIT, voidquit);
cdevname = filesys;
if (debug && preen)
pwarn("starting\n");
@ -299,8 +295,8 @@ checkfilesys(filesys, mntpt, auxdata, child)
return (0);
case -1:
clean:
pwarn("clean, %ld free ", sblock.fs_cstotal.cs_nffree +
sblock.fs_frag * sblock.fs_cstotal.cs_nbfree);
pwarn("clean, %ld free ", (long)(sblock.fs_cstotal.cs_nffree +
sblock.fs_frag * sblock.fs_cstotal.cs_nbfree));
printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
sblock.fs_cstotal.cs_nffree, sblock.fs_cstotal.cs_nbfree,
sblock.fs_cstotal.cs_nffree * 100.0 / sblock.fs_dsize);
@ -374,11 +370,12 @@ checkfilesys(filesys, mntpt, auxdata, child)
blks = maxfsblock - (n_ffree + sblock.fs_frag * n_bfree) - blks;
if (bkgrdflag && (files > 0 || blks > 0)) {
countdirs = sblock.fs_cstotal.cs_ndir - countdirs;
pwarn("Reclaimed: %d directories, %d files, %d fragments\n",
countdirs, files - countdirs, blks);
pwarn("Reclaimed: %ld directories, %ld files, %d fragments\n",
countdirs, (long)files - countdirs, blks);
}
pwarn("%ld files, %ld used, %ld free ",
n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
(long)n_files, (long)n_blks, (long)(n_ffree +
sblock.fs_frag * n_bfree));
printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
n_ffree, n_bfree, n_ffree * 100.0 / sblock.fs_dsize);
if (debug) {

View File

@ -197,7 +197,8 @@ checkinode(inumber, idesc)
memcmp(dp->di_ib, zino.di_ib,
NIADDR * sizeof(ufs_daddr_t)) ||
dp->di_mode || dp->di_size) {
pfatal("PARTIALLY ALLOCATED INODE I=%lu", inumber);
pfatal("PARTIALLY ALLOCATED INODE I=%lu",
(u_long)inumber);
if (reply("CLEAR") == 1) {
dp = ginode(inumber);
clearinode(dp);
@ -339,7 +340,8 @@ checkinode(inumber, idesc)
idesc->id_entryno *= btodb(sblock.fs_fsize);
if (dp->di_blocks != idesc->id_entryno) {
pwarn("INCORRECT BLOCK COUNT I=%lu (%ld should be %ld)",
inumber, dp->di_blocks, idesc->id_entryno);
(u_long)inumber, (long)dp->di_blocks,
(long)idesc->id_entryno);
if (preen)
printf(" (CORRECTED)\n");
else if (reply("CORRECT") == 0)
@ -352,7 +354,7 @@ checkinode(inumber, idesc)
cmd.value = idesc->id_number;
cmd.size = idesc->id_entryno - dp->di_blocks;
if (debug)
printf("adjblkcnt ino %d amount %d\n",
printf("adjblkcnt ino %ld amount %ld\n",
(long)cmd.value, cmd.size);
if (sysctl(adjblkcnt, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
@ -361,7 +363,7 @@ checkinode(inumber, idesc)
}
return;
unknown:
pfatal("UNKNOWN FILE TYPE I=%lu", inumber);
pfatal("UNKNOWN FILE TYPE I=%lu", (u_long)inumber);
inoinfo(inumber)->ino_state = FCLEAR;
if (reply("CLEAR") == 1) {
inoinfo(inumber)->ino_state = USTATE;
@ -400,7 +402,7 @@ pass1check(idesc)
blkerror(idesc->id_number, "BAD", blkno);
if (badblk++ >= MAXBAD) {
pwarn("EXCESSIVE BAD BLKS I=%lu",
idesc->id_number);
(u_long)idesc->id_number);
if (preen)
printf(" (SKIPPING)\n");
else if (reply("CONTINUE") == 0) {
@ -420,7 +422,7 @@ pass1check(idesc)
blkerror(idesc->id_number, "DUP", blkno);
if (dupblk++ >= MAXDUP) {
pwarn("EXCESSIVE DUP BLKS I=%lu",
idesc->id_number);
(u_long)idesc->id_number);
if (preen)
printf(" (SKIPPING)\n");
else if (reply("CONTINUE") == 0) {

View File

@ -137,8 +137,8 @@ pass2()
for (inpp = inpsort; inpp < inpend; inpp++) {
if (got_siginfo) {
printf("%s: phase 2: dir %d of %d (%d%%)\n", cdevname,
inpp - inpsort, inplast, (inpp - inpsort) * 100 /
inplast);
inpp - inpsort, (int)inplast,
(int)((inpp - inpsort) * 100 / inplast));
got_siginfo = 0;
}
inp = *inpp;

View File

@ -61,8 +61,8 @@ pass3()
for (inpindex = inplast - 1; inpindex >= 0; inpindex--) {
if (got_siginfo) {
printf("%s: phase 3: dir %d of %d (%d%%)\n", cdevname,
inplast - inpindex - 1, inplast,
(inplast - inpindex - 1) * 100 / inplast);
(int)(inplast - inpindex - 1), (int)inplast,
(int)((inplast - inpindex - 1) * 100 / inplast));
got_siginfo = 0;
}
inp = inpsort[inpindex];
@ -101,7 +101,8 @@ pass3()
propagate();
continue;
}
pfatal("ORPHANED DIRECTORY LOOP DETECTED I=%lu", orphan);
pfatal("ORPHANED DIRECTORY LOOP DETECTED I=%lu",
(u_long)orphan);
if (reply("RECONNECT") == 0)
continue;
memset(&idesc, 0, sizeof(struct inodesc));

View File

@ -237,7 +237,7 @@ pass5()
default:
if (j < (int)ROOTINO)
break;
errx(EEXIT, "BAD STATE %d FOR INODE I=%ld",
errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
inoinfo(j)->ino_state, j);
}
}
@ -435,7 +435,7 @@ check_maps(map1, map2, mapsize, startvalue, name, opcode, skip, limit)
pwarn("%s %s %d MARKED USED\n",
"UNALLOCATED", name, ustart);
else if (debug)
pwarn("%s %sS %d-%d MARKED USED\n",
pwarn("%s %sS %d-%ld MARKED USED\n",
"UNALLOCATED", name, ustart,
ustart + size - 1);
if (bkgrdflag != 0) {
@ -455,12 +455,13 @@ check_maps(map1, map2, mapsize, startvalue, name, opcode, skip, limit)
}
}
}
if (astart != -1)
if (astart != -1) {
if (astart == aend)
(*msg)("ALLOCATED %s %d MARKED FREE\n", name, astart);
else
(*msg)("ALLOCATED %sS %d-%d MARKED FREE\n",
name, astart, aend);
}
if (ustart != -1) {
size = uend - ustart + 1;
if (size <= skip)
@ -476,7 +477,7 @@ check_maps(map1, map2, mapsize, startvalue, name, opcode, skip, limit)
pwarn("UNALLOCATED %s %d MARKED USED\n",
name, ustart);
else
pwarn("UNALLOCATED %sS %d-%d MARKED USED\n",
pwarn("UNALLOCATED %sS %d-%ld MARKED USED\n",
name, ustart, ustart + size - 1);
}
if (bkgrdflag != 0) {

View File

@ -44,6 +44,7 @@ static const char rcsid[] =
#include <sys/stat.h>
#include <sys/disklabel.h>
#include <sys/file.h>
#include <sys/sysctl.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@ -72,11 +73,12 @@ int
setup(dev)
char *dev;
{
long cg, size, asked, i, j;
long cg, asked, i, j;
long bmapsize;
off_t sizepb;
struct stat statb;
struct fs proto;
size_t size;
havesb = 0;
fswritefd = -1;

View File

@ -64,8 +64,8 @@ char *
blockcheck(origname)
char *origname;
{
struct stat stslash, stblock, stchar;
char *newname, *raw, *cp;
struct stat stblock;
char *newname, *cp;
struct fstab *fsinfo;
int retried = 0, len;
static char device[MAXPATHLEN];