lint (from Torek)
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 21 Jul 1990 07:51:49 +0000 (23:51 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 21 Jul 1990 07:51:49 +0000 (23:51 -0800)
SCCS-vsn: sbin/fsck/pass4.c 5.10
SCCS-vsn: sbin/fsck/main.c 5.26
SCCS-vsn: sbin/fsck/utilities.c 5.28
SCCS-vsn: sbin/fsck/setup.c 5.31
SCCS-vsn: sbin/fsck/pass1.c 5.15
SCCS-vsn: sbin/fsck/dir.c 5.18
SCCS-vsn: sbin/fsck/inode.c 5.16
SCCS-vsn: sbin/fsck/fsck.h 5.16
SCCS-vsn: sbin/fsck/pass1b.c 5.8
SCCS-vsn: sbin/fsck/pass5.c 5.13
SCCS-vsn: sbin/fsck/pass2.c 5.14
SCCS-vsn: sbin/fsck/preen.c 5.5

12 files changed:
usr/src/sbin/fsck/dir.c
usr/src/sbin/fsck/fsck.h
usr/src/sbin/fsck/inode.c
usr/src/sbin/fsck/main.c
usr/src/sbin/fsck/pass1.c
usr/src/sbin/fsck/pass1b.c
usr/src/sbin/fsck/pass2.c
usr/src/sbin/fsck/pass4.c
usr/src/sbin/fsck/pass5.c
usr/src/sbin/fsck/preen.c
usr/src/sbin/fsck/setup.c
usr/src/sbin/fsck/utilities.c

index fbd38d8..7aa3b9e 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dir.c      5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)dir.c      5.18 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -15,6 +15,8 @@ static char sccsid[] = "@(#)dir.c     5.17 (Berkeley) %G%";
 #define KERNEL
 #include <ufs/dir.h>
 #undef KERNEL
 #define KERNEL
 #include <ufs/dir.h>
 #undef KERNEL
+#include <stdlib.h>
+#include <string.h>
 #include "fsck.h"
 
 char   *lfname = "lost+found";
 #include "fsck.h"
 
 char   *lfname = "lost+found";
@@ -75,12 +77,12 @@ dirscan(idesc)
        idesc->id_loc = 0;
        for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
                dsize = dp->d_reclen;
        idesc->id_loc = 0;
        for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
                dsize = dp->d_reclen;
-               bcopy((char *)dp, dbuf, dsize);
+               bcopy((char *)dp, dbuf, (size_t)dsize);
                idesc->id_dirp = (struct direct *)dbuf;
                if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
                        bp = getdirblk(idesc->id_blkno, blksiz);
                        bcopy(dbuf, bp->b_un.b_buf + idesc->id_loc - dsize,
                idesc->id_dirp = (struct direct *)dbuf;
                if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
                        bp = getdirblk(idesc->id_blkno, blksiz);
                        bcopy(dbuf, bp->b_un.b_buf + idesc->id_loc - dsize,
-                           dsize);
+                           (size_t)dsize);
                        dirty(bp);
                        sbdirty();
                }
                        dirty(bp);
                        sbdirty();
                }
@@ -259,7 +261,7 @@ mkentry(idesc)
        dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */
        dirp->d_reclen = newent.d_reclen;
        dirp->d_namlen = newent.d_namlen;
        dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */
        dirp->d_reclen = newent.d_reclen;
        dirp->d_namlen = newent.d_namlen;
-       bcopy(idesc->id_name, dirp->d_name, (int)dirp->d_namlen + 1);
+       bcopy(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1);
        return (ALTERED|STOP);
 }
 
        return (ALTERED|STOP);
 }
 
@@ -364,14 +366,14 @@ linkup(orphan, parentdir)
        if (lostdir) {
                if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
                    parentdir != (ino_t)-1)
        if (lostdir) {
                if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
                    parentdir != (ino_t)-1)
-                       makeentry(orphan, lfdir, "..");
+                       (void)makeentry(orphan, lfdir, "..");
                dp = ginode(lfdir);
                dp->di_nlink++;
                inodirty();
                lncntp[lfdir]++;
                dp = ginode(lfdir);
                dp->di_nlink++;
                inodirty();
                lncntp[lfdir]++;
-               pwarn("DIR I=%u CONNECTED. ", orphan);
+               pwarn("DIR I=%lu CONNECTED. ", orphan);
                if (parentdir != (ino_t)-1)
                if (parentdir != (ino_t)-1)
-                       printf("PARENT WAS I=%u\n", parentdir);
+                       printf("PARENT WAS I=%lu\n", parentdir);
                if (preen == 0)
                        printf("\n");
        }
                if (preen == 0)
                        printf("\n");
        }
@@ -454,7 +456,7 @@ expanddir(dp, name)
        dp->di_size += sblock.fs_bsize;
        dp->di_blocks += btodb(sblock.fs_bsize);
        bp = getdirblk(dp->di_db[lastbn + 1],
        dp->di_size += sblock.fs_bsize;
        dp->di_blocks += btodb(sblock.fs_bsize);
        bp = getdirblk(dp->di_db[lastbn + 1],
-               dblksize(&sblock, dp, lastbn + 1));
+               (long)dblksize(&sblock, dp, lastbn + 1));
        if (bp->b_errs)
                goto bad;
        bcopy(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
        if (bp->b_errs)
                goto bad;
        bcopy(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
@@ -468,7 +470,7 @@ expanddir(dp, name)
                bcopy((char *)&emptydir, cp, sizeof emptydir);
        dirty(bp);
        bp = getdirblk(dp->di_db[lastbn + 1],
                bcopy((char *)&emptydir, cp, sizeof emptydir);
        dirty(bp);
        bp = getdirblk(dp->di_db[lastbn + 1],
-               dblksize(&sblock, dp, lastbn + 1));
+               (long)dblksize(&sblock, dp, lastbn + 1));
        if (bp->b_errs)
                goto bad;
        bcopy((char *)&emptydir, bp->b_un.b_buf, sizeof emptydir);
        if (bp->b_errs)
                goto bad;
        bcopy((char *)&emptydir, bp->b_un.b_buf, sizeof emptydir);
index 7dd7478..6dd559e 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)fsck.h      5.15 (Berkeley) %G%
+ *     @(#)fsck.h      5.16 (Berkeley) %G%
  */
 
 #define        MAXDUP          10      /* limit on dup blks (per inode) */
  */
 
 #define        MAXDUP          10      /* limit on dup blks (per inode) */
@@ -180,6 +180,6 @@ struct      dinode zino;
 time_t time();
 struct dinode *ginode();
 struct inoinfo *getinoinfo();
 time_t time();
 struct dinode *ginode();
 struct inoinfo *getinoinfo();
-struct bufarea *getblk();
+void getblk();
 ino_t allocino();
 int findino();
 ino_t allocino();
 int findino();
index d141aed..39ac7a5 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)inode.c    5.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)inode.c    5.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -14,6 +14,8 @@ static char sccsid[] = "@(#)inode.c   5.15 (Berkeley) %G%";
 #include <ufs/fs.h>
 #include <ufs/dir.h>
 #include <pwd.h>
 #include <ufs/fs.h>
 #include <ufs/dir.h>
 #include <pwd.h>
+#include <stdlib.h>
+#include <string.h>
 #include "fsck.h"
 
 static ino_t startinum;
 #include "fsck.h"
 
 static ino_t startinum;
@@ -65,7 +67,7 @@ ckinode(dp, idesc)
 iblock(idesc, ilevel, isize)
        struct inodesc *idesc;
        register long ilevel;
 iblock(idesc, ilevel, isize)
        struct inodesc *idesc;
        register long ilevel;
-       long isize;
+       u_long isize;
 {
        register daddr_t *ap;
        register daddr_t *aplim;
 {
        register daddr_t *ap;
        register daddr_t *aplim;
@@ -94,7 +96,7 @@ iblock(idesc, ilevel, isize)
                for (ap = &bp->b_un.b_indir[nif]; ap < aplim; ap++) {
                        if (*ap == 0)
                                continue;
                for (ap = &bp->b_un.b_indir[nif]; ap < aplim; ap++) {
                        if (*ap == 0)
                                continue;
-                       (void)sprintf(buf, "PARTIALLY TRUNCATED INODE I=%d",
+                       (void)sprintf(buf, "PARTIALLY TRUNCATED INODE I=%lu",
                                idesc->id_number);
                        if (dofix(idesc, buf)) {
                                *ap = 0;
                                idesc->id_number);
                        if (dofix(idesc, buf)) {
                                *ap = 0;
@@ -137,9 +139,9 @@ chkrange(blk, cnt)
        if (blk < cgdmin(&sblock, c)) {
                if ((blk + cnt) > cgsblock(&sblock, c)) {
                        if (debug) {
        if (blk < cgdmin(&sblock, c)) {
                if ((blk + cnt) > cgsblock(&sblock, c)) {
                        if (debug) {
-                               printf("blk %d < cgdmin %d;",
+                               printf("blk %ld < cgdmin %ld;",
                                    blk, cgdmin(&sblock, c));
                                    blk, cgdmin(&sblock, c));
-                               printf(" blk + cnt %d > cgsbase %d\n",
+                               printf(" blk + cnt %ld > cgsbase %ld\n",
                                    blk + cnt, cgsblock(&sblock, c));
                        }
                        return (1);
                                    blk + cnt, cgsblock(&sblock, c));
                        }
                        return (1);
@@ -147,9 +149,9 @@ chkrange(blk, cnt)
        } else {
                if ((blk + cnt) > cgbase(&sblock, c+1)) {
                        if (debug)  {
        } else {
                if ((blk + cnt) > cgbase(&sblock, c+1)) {
                        if (debug)  {
-                               printf("blk %d >= cgdmin %d;",
+                               printf("blk %ld >= cgdmin %ld;",
                                    blk, cgdmin(&sblock, c));
                                    blk, cgdmin(&sblock, c));
-                               printf(" blk + cnt %d > sblock.fs_fpg %d\n",
+                               printf(" blk + cnt %ld > sblock.fs_fpg %ld\n",
                                    blk+cnt, sblock.fs_fpg);
                        }
                        return (1);
                                    blk+cnt, sblock.fs_fpg);
                        }
                        return (1);
@@ -208,7 +210,7 @@ getnextinode(inumber)
                        size = inobufsize;
                        lastinum += fullcnt;
                }
                        size = inobufsize;
                        lastinum += fullcnt;
                }
-               bread(fsreadfd, (char *)inodebuf, dblk, size);
+               (void)bread(fsreadfd, (char *)inodebuf, dblk, size); /* ??? */
                dp = inodebuf;
        }
        return (dp++);
                dp = inodebuf;
        }
        return (dp++);
@@ -236,7 +238,7 @@ resetinodebuf()
            (inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL)
                errexit("Cannot allocate space for inode buffer\n");
        while (nextino < ROOTINO)
            (inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL)
                errexit("Cannot allocate space for inode buffer\n");
        while (nextino < ROOTINO)
-               getnextinode(nextino);
+               (void)getnextinode(nextino);
 }
 
 freeinodebuf()
 }
 
 freeinodebuf()
@@ -278,7 +280,7 @@ cacheino(dp, inumber)
        inp->i_isize = dp->di_size;
        inp->i_numblks = blks * sizeof(daddr_t);
        bcopy((char *)&dp->di_db[0], (char *)&inp->i_blks[0],
        inp->i_isize = dp->di_size;
        inp->i_numblks = blks * sizeof(daddr_t);
        bcopy((char *)&dp->di_db[0], (char *)&inp->i_blks[0],
-           (int)inp->i_numblks);
+           (size_t)inp->i_numblks);
        if (inplast == listmax) {
                listmax += 100;
                inpsort = (struct inoinfo **)realloc((char *)inpsort,
        if (inplast == listmax) {
                listmax += 100;
                inpsort = (struct inoinfo **)realloc((char *)inpsort,
@@ -360,7 +362,7 @@ findname(idesc)
 
        if (dirp->d_ino != idesc->id_parent)
                return (KEEPON);
 
        if (dirp->d_ino != idesc->id_parent)
                return (KEEPON);
-       bcopy(dirp->d_name, idesc->id_name, (int)dirp->d_namlen + 1);
+       bcopy(dirp->d_name, idesc->id_name, (size_t)dirp->d_namlen + 1);
        return (STOP|FOUND);
 }
 
        return (STOP|FOUND);
 }
 
@@ -387,7 +389,7 @@ pinode(ino)
        struct passwd *pw;
        char *ctime();
 
        struct passwd *pw;
        char *ctime();
 
-       printf(" I=%u ", ino);
+       printf(" I=%lu ", ino);
        if (ino < ROOTINO || ino > maxino)
                return;
        dp = ginode(ino);
        if (ino < ROOTINO || ino > maxino)
                return;
        dp = ginode(ino);
@@ -395,11 +397,11 @@ pinode(ino)
        if ((pw = getpwuid((int)dp->di_uid)) != 0)
                printf("%s ", pw->pw_name);
        else
        if ((pw = getpwuid((int)dp->di_uid)) != 0)
                printf("%s ", pw->pw_name);
        else
-               printf("%d ", dp->di_uid);
+               printf("%u ", (unsigned)dp->di_uid);
        printf("MODE=%o\n", dp->di_mode);
        if (preen)
                printf("%s: ", devname);
        printf("MODE=%o\n", dp->di_mode);
        if (preen)
                printf("%s: ", devname);
-       printf("SIZE=%ld ", dp->di_size);
+       printf("SIZE=%lu ", dp->di_size);
        p = ctime(&dp->di_mtime);
        printf("MTIME=%12.12s %4.4s ", p + 4, p + 20);
 }
        p = ctime(&dp->di_mtime);
        printf("MTIME=%12.12s %4.4s ", p + 4, p + 20);
 }
@@ -410,7 +412,7 @@ blkerror(ino, type, blk)
        daddr_t blk;
 {
 
        daddr_t blk;
 {
 
-       pfatal("%ld %s I=%u", blk, type, ino);
+       pfatal("%ld %s I=%lu", blk, type, ino);
        printf("\n");
        switch (statemap[ino]) {
 
        printf("\n");
        switch (statemap[ino]) {
 
@@ -470,7 +472,7 @@ allocino(request, type)
                return (0);
        }
        dp->di_mode = type;
                return (0);
        }
        dp->di_mode = type;
-       time(&dp->di_atime);
+       (void)time(&dp->di_atime);
        dp->di_mtime = dp->di_ctime = dp->di_atime;
        dp->di_size = sblock.fs_fsize;
        dp->di_blocks = btodb(sblock.fs_fsize);
        dp->di_mtime = dp->di_ctime = dp->di_atime;
        dp->di_size = sblock.fs_fsize;
        dp->di_blocks = btodb(sblock.fs_fsize);
index d0f8612..167a6c9 100644 (file)
@@ -12,13 +12,14 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.25 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.26 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
 #include <fstab.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
 #include <fstab.h>
+#include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdio.h>
@@ -31,7 +32,7 @@ main(argc, argv)
        int     argc;
        char    *argv[];
 {
        int     argc;
        char    *argv[];
 {
-       char ch;
+       int ch;
        int ret, maxrun = 0;
        extern int docheck(), checkfilesys();
        extern char *optarg;
        int ret, maxrun = 0;
        extern int docheck(), checkfilesys();
        extern char *optarg;
@@ -45,9 +46,7 @@ main(argc, argv)
                        break;
 
                case 'b':
                        break;
 
                case 'b':
-                       if (!isdigit(*optarg))
-                               errexit("-b flag requires a number\n");
-                       bflag = atoi(optarg);
+                       bflag = argtoi('b', "number", optarg, 10);
                        printf("Alternate super block location: %d\n", bflag);
                        break;
 
                        printf("Alternate super block location: %d\n", bflag);
                        break;
 
@@ -60,15 +59,11 @@ main(argc, argv)
                        break;
 
                case 'l':
                        break;
 
                case 'l':
-                       if (!isdigit(*optarg))
-                               errexit("-l flag requires a number\n");
-                       maxrun = atoi(optarg);
+                       maxrun = argtoi('l', "number", optarg, 10);
                        break;
 
                case 'm':
                        break;
 
                case 'm':
-                       if (!isdigit(*optarg))
-                               errexit("-m flag requires a mode\n");
-                       sscanf(optarg, "%o", &lfmode);
+                       lfmode = argtoi('m', "mode", optarg, 8);
                        if (lfmode &~ 07777)
                                errexit("bad mode to -m: %o\n", lfmode);
                        printf("** lost+found creation mode %o\n", lfmode);
                        if (lfmode &~ 07777)
                                errexit("bad mode to -m: %o\n", lfmode);
                        printf("** lost+found creation mode %o\n", lfmode);
@@ -98,7 +93,7 @@ main(argc, argv)
                (void)signal(SIGQUIT, catchquit);
        if (argc) {
                while (argc-- > 0)
                (void)signal(SIGQUIT, catchquit);
        if (argc) {
                while (argc-- > 0)
-                       checkfilesys(*argv++, (char *)0, 0);
+                       (void)checkfilesys(*argv++, (char *)0, 0L);
                exit(0);
        }
        ret = checkfstab(preen, maxrun, docheck, checkfilesys);
                exit(0);
        }
        ret = checkfstab(preen, maxrun, docheck, checkfilesys);
@@ -107,6 +102,20 @@ main(argc, argv)
        exit(ret);
 }
 
        exit(ret);
 }
 
+argtoi(flag, req, str, base)
+       int flag;
+       char *req, *str;
+       int base;
+{
+       char *cp;
+       int ret;
+
+       ret = (int)strtol(str, &cp, base);
+       if (cp == str || *cp)
+               errexit("-%c flag requires a %s\n", flag, req);
+       return (ret);
+}
+
 /*
  * Determine whether a filesystem should be checked.
  */
 /*
  * Determine whether a filesystem should be checked.
  */
@@ -197,30 +206,30 @@ checkfilesys(filesys, mntpt, auxdata)
         */
        n_ffree = sblock.fs_cstotal.cs_nffree;
        n_bfree = sblock.fs_cstotal.cs_nbfree;
         */
        n_ffree = sblock.fs_cstotal.cs_nffree;
        n_bfree = sblock.fs_cstotal.cs_nbfree;
-       pwarn("%d files, %d used, %d free ",
+       pwarn("%ld files, %ld used, %ld free ",
            n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
            n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
-       printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
+       printf("(%ld frags, %ld blocks, %.1f%% fragmentation)\n",
            n_ffree, n_bfree, (float)(n_ffree * 100) / sblock.fs_dsize);
        if (debug &&
            (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree))
            n_ffree, n_bfree, (float)(n_ffree * 100) / sblock.fs_dsize);
        if (debug &&
            (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree))
-               printf("%d files missing\n", n_files);
+               printf("%ld files missing\n", n_files);
        if (debug) {
                n_blks += sblock.fs_ncg *
                        (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
                n_blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);
                n_blks += howmany(sblock.fs_cssize, sblock.fs_fsize);
                if (n_blks -= maxfsblock - (n_ffree + sblock.fs_frag * n_bfree))
        if (debug) {
                n_blks += sblock.fs_ncg *
                        (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
                n_blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);
                n_blks += howmany(sblock.fs_cssize, sblock.fs_fsize);
                if (n_blks -= maxfsblock - (n_ffree + sblock.fs_frag * n_bfree))
-                       printf("%d blocks missing\n", n_blks);
+                       printf("%ld blocks missing\n", n_blks);
                if (duplist != NULL) {
                        printf("The following duplicate blocks remain:");
                        for (dp = duplist; dp; dp = dp->next)
                if (duplist != NULL) {
                        printf("The following duplicate blocks remain:");
                        for (dp = duplist; dp; dp = dp->next)
-                               printf(" %d,", dp->dup);
+                               printf(" %ld,", dp->dup);
                        printf("\n");
                }
                if (zlnhead != NULL) {
                        printf("The following zero link count inodes remain:");
                        for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
                        printf("\n");
                }
                if (zlnhead != NULL) {
                        printf("The following zero link count inodes remain:");
                        for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
-                               printf(" %d,", zlnp->zlncnt);
+                               printf(" %lu,", zlnp->zlncnt);
                        printf("\n");
                }
        }
                        printf("\n");
                }
        }
index f1da36c..2c5538e 100644 (file)
@@ -6,12 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pass1.c    5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)pass1.c    5.15 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
+#include <stdlib.h>
+#include <string.h>
 #include "fsck.h"
 
 static daddr_t badblk;
 #include "fsck.h"
 
 static daddr_t badblk;
@@ -61,7 +63,7 @@ pass1()
                                    bcmp((char *)dp->di_ib, (char *)zino.di_ib,
                                        NIADDR * sizeof(daddr_t)) ||
                                    dp->di_mode || dp->di_size) {
                                    bcmp((char *)dp->di_ib, (char *)zino.di_ib,
                                        NIADDR * sizeof(daddr_t)) ||
                                    dp->di_mode || dp->di_size) {
-                                       pfatal("PARTIALLY ALLOCATED INODE I=%u",
+                                       pfatal("PARTIALLY ALLOCATED INODE I=%lu",
                                                inumber);
                                        if (reply("CLEAR") == 1) {
                                                dp = ginode(inumber);
                                                inumber);
                                        if (reply("CLEAR") == 1) {
                                                dp = ginode(inumber);
@@ -73,10 +75,10 @@ pass1()
                                continue;
                        }
                        lastino = inumber;
                                continue;
                        }
                        lastino = inumber;
-                       if (dp->di_size < 0 ||
-                           dp->di_size + sblock.fs_bsize - 1 < 0) {
+                       if (/* dp->di_size < 0 || */
+                           dp->di_size + sblock.fs_bsize - 1 < dp->di_size) {
                                if (debug)
                                if (debug)
-                                       printf("bad size %d:", dp->di_size);
+                                       printf("bad size %lu:", dp->di_size);
                                goto unknown;
                        }
                        if (!preen && (dp->di_mode & IFMT) == IFMT &&
                                goto unknown;
                        }
                        if (!preen && (dp->di_mode & IFMT) == IFMT &&
@@ -89,7 +91,7 @@ pass1()
                        ndb = howmany(dp->di_size, sblock.fs_bsize);
                        if (ndb < 0) {
                                if (debug)
                        ndb = howmany(dp->di_size, sblock.fs_bsize);
                        if (ndb < 0) {
                                if (debug)
-                                       printf("bad size %d ndb %d:",
+                                       printf("bad size %lu ndb %d:",
                                                dp->di_size, ndb);
                                goto unknown;
                        }
                                                dp->di_size, ndb);
                                goto unknown;
                        }
@@ -99,7 +101,7 @@ pass1()
                        for (j = ndb; j < NDADDR; j++)
                                if (dp->di_db[j] != 0) {
                                        if (debug)
                        for (j = ndb; j < NDADDR; j++)
                                if (dp->di_db[j] != 0) {
                                        if (debug)
-                                               printf("bad direct addr: %d\n",
+                                               printf("bad direct addr: %ld\n",
                                                        dp->di_db[j]);
                                        goto unknown;
                                }
                                                        dp->di_db[j]);
                                        goto unknown;
                                }
@@ -108,7 +110,7 @@ pass1()
                        for (; j < NIADDR; j++)
                                if (dp->di_ib[j] != 0) {
                                        if (debug)
                        for (; j < NIADDR; j++)
                                if (dp->di_ib[j] != 0) {
                                        if (debug)
-                                               printf("bad indirect addr: %d\n",
+                                               printf("bad indirect addr: %ld\n",
                                                        dp->di_ib[j]);
                                        goto unknown;
                                }
                                                        dp->di_ib[j]);
                                        goto unknown;
                                }
@@ -141,7 +143,7 @@ pass1()
                        (void)ckinode(dp, &idesc);
                        idesc.id_entryno *= btodb(sblock.fs_fsize);
                        if (dp->di_blocks != idesc.id_entryno) {
                        (void)ckinode(dp, &idesc);
                        idesc.id_entryno *= btodb(sblock.fs_fsize);
                        if (dp->di_blocks != idesc.id_entryno) {
-                               pwarn("INCORRECT BLOCK COUNT I=%u (%ld should be %ld)",
+                               pwarn("INCORRECT BLOCK COUNT I=%lu (%ld should be %ld)",
                                    inumber, dp->di_blocks, idesc.id_entryno);
                                if (preen)
                                        printf(" (CORRECTED)\n");
                                    inumber, dp->di_blocks, idesc.id_entryno);
                                if (preen)
                                        printf(" (CORRECTED)\n");
@@ -153,7 +155,7 @@ pass1()
                        }
                        continue;
        unknown:
                        }
                        continue;
        unknown:
-                       pfatal("UNKNOWN FILE TYPE I=%u", inumber);
+                       pfatal("UNKNOWN FILE TYPE I=%lu", inumber);
                        statemap[inumber] = FCLEAR;
                        if (reply("CLEAR") == 1) {
                                statemap[inumber] = USTATE;
                        statemap[inumber] = FCLEAR;
                        if (reply("CLEAR") == 1) {
                                statemap[inumber] = USTATE;
@@ -178,7 +180,7 @@ pass1check(idesc)
        if ((anyout = chkrange(blkno, idesc->id_numfrags)) != 0) {
                blkerror(idesc->id_number, "BAD", blkno);
                if (++badblk >= MAXBAD) {
        if ((anyout = chkrange(blkno, idesc->id_numfrags)) != 0) {
                blkerror(idesc->id_number, "BAD", blkno);
                if (++badblk >= MAXBAD) {
-                       pwarn("EXCESSIVE BAD BLKS I=%u",
+                       pwarn("EXCESSIVE BAD BLKS I=%lu",
                                idesc->id_number);
                        if (preen)
                                printf(" (SKIPPING)\n");
                                idesc->id_number);
                        if (preen)
                                printf(" (SKIPPING)\n");
@@ -196,7 +198,7 @@ pass1check(idesc)
                } else {
                        blkerror(idesc->id_number, "DUP", blkno);
                        if (++dupblk >= MAXDUP) {
                } else {
                        blkerror(idesc->id_number, "DUP", blkno);
                        if (++dupblk >= MAXDUP) {
-                               pwarn("EXCESSIVE DUP BLKS I=%u",
+                               pwarn("EXCESSIVE DUP BLKS I=%lu",
                                        idesc->id_number);
                                if (preen)
                                        printf(" (SKIPPING)\n");
                                        idesc->id_number);
                                if (preen)
                                        printf(" (SKIPPING)\n");
index 0cc5016..920df1a 100644 (file)
@@ -6,12 +6,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pass1b.c   5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)pass1b.c   5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
+#include <string.h>
 #include "fsck.h"
 
 int    pass1bcheck();
 #include "fsck.h"
 
 int    pass1bcheck();
index 557295a..23c5401 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pass2.c    5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)pass2.c    5.14 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -15,6 +15,7 @@ static char sccsid[] = "@(#)pass2.c   5.13 (Berkeley) %G%";
 #define KERNEL
 #include <ufs/dir.h>
 #undef KERNEL
 #define KERNEL
 #include <ufs/dir.h>
 #undef KERNEL
+#include <stdlib.h>
 #include <string.h>
 #include "fsck.h"
 
 #include <string.h>
 #include "fsck.h"
 
@@ -80,7 +81,7 @@ pass2()
        /*
         * Sort the directory list into disk block order.
         */
        /*
         * Sort the directory list into disk block order.
         */
-       qsort((char *)inpsort, (int)inplast, sizeof *inpsort, blksort);
+       qsort((char *)inpsort, (size_t)inplast, sizeof *inpsort, blksort);
        /*
         * Check the integrity of each directory.
         */
        /*
         * Check the integrity of each directory.
         */
@@ -119,7 +120,7 @@ pass2()
                }
                dp->di_size = inp->i_isize;
                bcopy((char *)&inp->i_blks[0], (char *)&dp->di_db[0],
                }
                dp->di_size = inp->i_isize;
                bcopy((char *)&inp->i_blks[0], (char *)&dp->di_db[0],
-                       (int)inp->i_numblks);
+                       (size_t)inp->i_numblks);
                curino.id_number = inp->i_number;
                curino.id_parent = inp->i_parent;
                (void)ckinode(dp, &curino);
                curino.id_number = inp->i_number;
                curino.id_parent = inp->i_parent;
                (void)ckinode(dp, &curino);
@@ -143,7 +144,7 @@ pass2()
                        fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
                        if (reply("FIX") == 0)
                                continue;
                        fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
                        if (reply("FIX") == 0)
                                continue;
-                       makeentry(inp->i_number, inp->i_parent, "..");
+                       (void)makeentry(inp->i_number, inp->i_parent, "..");
                        lncntp[inp->i_parent]--;
                        continue;
                }
                        lncntp[inp->i_parent]--;
                        continue;
                }
@@ -200,17 +201,17 @@ pass2check(idesc)
                pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
        } else if (dirp->d_reclen < 2 * entrysize) {
                proto.d_reclen = dirp->d_reclen;
                pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
        } else if (dirp->d_reclen < 2 * entrysize) {
                proto.d_reclen = dirp->d_reclen;
-               bcopy((char *)&proto, (char *)dirp, entrysize);
+               bcopy((char *)&proto, (char *)dirp, (size_t)entrysize);
                if (reply("FIX") == 1)
                        ret |= ALTERED;
        } else {
                n = dirp->d_reclen - entrysize;
                proto.d_reclen = entrysize;
                if (reply("FIX") == 1)
                        ret |= ALTERED;
        } else {
                n = dirp->d_reclen - entrysize;
                proto.d_reclen = entrysize;
-               bcopy((char *)&proto, (char *)dirp, entrysize);
+               bcopy((char *)&proto, (char *)dirp, (size_t)entrysize);
                idesc->id_entryno++;
                lncntp[dirp->d_ino]--;
                dirp = (struct direct *)((char *)(dirp) + entrysize);
                idesc->id_entryno++;
                lncntp[dirp->d_ino]--;
                dirp = (struct direct *)((char *)(dirp) + entrysize);
-               bzero((char *)dirp, n);
+               bzero((char *)dirp, (size_t)n);
                dirp->d_reclen = n;
                if (reply("FIX") == 1)
                        ret |= ALTERED;
                dirp->d_reclen = n;
                if (reply("FIX") == 1)
                        ret |= ALTERED;
@@ -232,7 +233,7 @@ chk1:
                idesc->id_entryno++;
                lncntp[dirp->d_ino]--;
                dirp = (struct direct *)((char *)(dirp) + n);
                idesc->id_entryno++;
                lncntp[dirp->d_ino]--;
                dirp = (struct direct *)((char *)(dirp) + n);
-               bzero((char *)dirp, (int)proto.d_reclen);
+               bzero((char *)dirp, (size_t)proto.d_reclen);
                dirp->d_reclen = proto.d_reclen;
        }
        if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) {
                dirp->d_reclen = proto.d_reclen;
        }
        if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) {
@@ -255,7 +256,7 @@ chk1:
                inp->i_dotdot = inp->i_parent;
                fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
                proto.d_reclen = dirp->d_reclen;
                inp->i_dotdot = inp->i_parent;
                fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
                proto.d_reclen = dirp->d_reclen;
-               bcopy((char *)&proto, (char *)dirp, entrysize);
+               bcopy((char *)&proto, (char *)dirp, (size_t)entrysize);
                if (reply("FIX") == 1)
                        ret |= ALTERED;
        }
                if (reply("FIX") == 1)
                        ret |= ALTERED;
        }
index aecef31..34f6f6a 100644 (file)
@@ -6,12 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pass4.c    5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)pass4.c    5.10 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
+#include <stdlib.h>
+#include <string.h>
 #include "fsck.h"
 
 int    pass4check();
 #include "fsck.h"
 
 int    pass4check();
index 4428aff..286cf10 100644 (file)
@@ -6,12 +6,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pass5.c    5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)pass5.c    5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
+#include <string.h>
 #include "fsck.h"
 
 pass5()
 #include "fsck.h"
 
 pass5()
@@ -30,7 +31,7 @@ pass5()
        register struct cg *newcg = (struct cg *)buf;
        struct ocg *ocg = (struct ocg *)buf;
 
        register struct cg *newcg = (struct cg *)buf;
        struct ocg *ocg = (struct ocg *)buf;
 
-       bzero((char *)newcg, (int)fs->fs_cgsize);
+       bzero((char *)newcg, (size_t)fs->fs_cgsize);
        newcg->cg_niblk = fs->fs_ipg;
        switch ((int)fs->fs_postblformat) {
 
        newcg->cg_niblk = fs->fs_ipg;
        switch ((int)fs->fs_postblformat) {
 
@@ -109,7 +110,8 @@ pass5()
                else
                        newcg->cg_irotor = 0;
                bzero((char *)&newcg->cg_frsum[0], sizeof newcg->cg_frsum);
                else
                        newcg->cg_irotor = 0;
                bzero((char *)&newcg->cg_frsum[0], sizeof newcg->cg_frsum);
-               bzero((char *)&cg_blktot(newcg)[0], sumsize + mapsize);
+               bzero((char *)&cg_blktot(newcg)[0],
+                     (size_t)(sumsize + mapsize));
                if (fs->fs_postblformat == FS_42POSTBLFMT)
                        ocg->cg_magic = CG_MAGIC;
                j = fs->fs_ipg * c;
                if (fs->fs_postblformat == FS_42POSTBLFMT)
                        ocg->cg_magic = CG_MAGIC;
                j = fs->fs_ipg * c;
@@ -175,23 +177,24 @@ pass5()
                        sbdirty();
                }
                if (cvtflag) {
                        sbdirty();
                }
                if (cvtflag) {
-                       bcopy((char *)newcg, (char *)cg, (int)fs->fs_cgsize);
+                       bcopy((char *)newcg, (char *)cg, (size_t)fs->fs_cgsize);
                        cgdirty();
                        continue;
                }
                if (bcmp(cg_inosused(newcg),
                         cg_inosused(cg), mapsize) != 0 &&
                    dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
                        cgdirty();
                        continue;
                }
                if (bcmp(cg_inosused(newcg),
                         cg_inosused(cg), mapsize) != 0 &&
                    dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
-                       bcopy(cg_inosused(newcg), cg_inosused(cg), mapsize);
+                       bcopy(cg_inosused(newcg), cg_inosused(cg),
+                             (size_t)mapsize);
                        cgdirty();
                }
                if ((bcmp((char *)newcg, (char *)cg, basesize) != 0 ||
                     bcmp((char *)&cg_blktot(newcg)[0],
                          (char *)&cg_blktot(cg)[0], sumsize) != 0) &&
                    dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
                        cgdirty();
                }
                if ((bcmp((char *)newcg, (char *)cg, basesize) != 0 ||
                     bcmp((char *)&cg_blktot(newcg)[0],
                          (char *)&cg_blktot(cg)[0], sumsize) != 0) &&
                    dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
-                       bcopy((char *)newcg, (char *)cg, basesize);
+                       bcopy((char *)newcg, (char *)cg, (size_t)basesize);
                        bcopy((char *)&cg_blktot(newcg)[0],
                        bcopy((char *)&cg_blktot(newcg)[0],
-                             (char *)&cg_blktot(cg)[0], sumsize);
+                             (char *)&cg_blktot(cg)[0], (size_t)sumsize);
                        cgdirty();
                }
        }
                        cgdirty();
                }
        }
index b530490..7599013 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)preen.c    5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)preen.c    5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -15,9 +15,10 @@ static char sccsid[] = "@(#)preen.c  5.4 (Berkeley) %G%";
 #include <fstab.h>
 #include <string.h>
 #include <stdio.h>
 #include <fstab.h>
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 
 #include <ctype.h>
 
-char   *rawname(), *unrawname(), *blockcheck(), *malloc();
+char   *rawname(), *unrawname(), *blockcheck();
 
 struct part {
        struct  part *next;             /* forward link of partitions on disk */
 
 struct part {
        struct  part *next;             /* forward link of partitions on disk */
@@ -165,7 +166,7 @@ finddisk(name)
 {
        register struct disk *dk, **dkp;
        register char *p;
 {
        register struct disk *dk, **dkp;
        register char *p;
-       int len;
+       size_t len;
 
        for (p = name + strlen(name) - 1; p >= name; --p)
                if (isdigit(*p)) {
 
        for (p = name + strlen(name) - 1; p >= name; --p)
                if (isdigit(*p)) {
@@ -185,11 +186,11 @@ finddisk(name)
                exit (8);
        }
        dk = *dkp;
                exit (8);
        }
        dk = *dkp;
-       if ((dk->name = malloc((unsigned int)len + 1)) == NULL) {
+       if ((dk->name = malloc(len + 1)) == NULL) {
                fprintf(stderr, "out of memory");
                exit (8);
        }
                fprintf(stderr, "out of memory");
                exit (8);
        }
-       strncpy(dk->name, name, len);
+       (void)strncpy(dk->name, name, len);
        dk->name[len] = '\0';
        dk->part = NULL;
        dk->next = NULL;
        dk->name[len] = '\0';
        dk->part = NULL;
        dk->next = NULL;
@@ -215,16 +216,16 @@ addpart(name, fsname, auxdata)
                exit (8);
        }
        pt = *ppt;
                exit (8);
        }
        pt = *ppt;
-       if ((pt->name = malloc((unsigned int)strlen(name) + 1)) == NULL) {
+       if ((pt->name = malloc(strlen(name) + 1)) == NULL) {
                fprintf(stderr, "out of memory");
                exit (8);
        }
                fprintf(stderr, "out of memory");
                exit (8);
        }
-       strcpy(pt->name, name);
-       if ((pt->fsname = malloc((unsigned int)strlen(fsname) + 1)) == NULL) {
+       (void)strcpy(pt->name, name);
+       if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) {
                fprintf(stderr, "out of memory");
                exit (8);
        }
                fprintf(stderr, "out of memory");
                exit (8);
        }
-       strcpy(pt->fsname, fsname);
+       (void)strcpy(pt->fsname, fsname);
        pt->next = NULL;
        pt->auxdata = auxdata;
 }
        pt->next = NULL;
        pt->auxdata = auxdata;
 }
index 700b414..b60a95f 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)setup.c    5.30 (Berkeley) %G%";
+static char sccsid[] = "@(#)setup.c    5.31 (Berkeley) %G%";
 #endif /* not lint */
 
 #define DKTYPENAMES
 #endif /* not lint */
 
 #define DKTYPENAMES
@@ -17,7 +17,9 @@ static char sccsid[] = "@(#)setup.c   5.30 (Berkeley) %G%";
 #include <sys/ioctl.h>
 #include <sys/disklabel.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/disklabel.h>
 #include <sys/file.h>
-#include <machine/endian.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
 #include <ctype.h>
 #include "fsck.h"
 
 #include <ctype.h>
 #include "fsck.h"
 
@@ -38,7 +40,6 @@ struct bufarea asblk;
     /* inode map */    howmany((fs)->fs_ipg, NBBY) + \
     /* block map */    howmany((fs)->fs_cpg * (fs)->fs_spc / NSPF(fs), NBBY))
 
     /* inode map */    howmany((fs)->fs_ipg, NBBY) + \
     /* block map */    howmany((fs)->fs_cpg * (fs)->fs_spc / NSPF(fs), NBBY))
 
-char   *malloc(), *calloc();
 char   *index();
 struct disklabel *getdisklabel();
 
 char   *index();
 struct disklabel *getdisklabel();
 
@@ -53,8 +54,7 @@ setup(dev)
 
        havesb = 0;
        if (stat(dev, &statb) < 0) {
 
        havesb = 0;
        if (stat(dev, &statb) < 0) {
-               perror(dev);
-               printf("Can't stat %s\n", dev);
+               printf("Can't stat %s: %s\n", dev, strerror(errno));
                return (0);
        }
        if ((statb.st_mode & S_IFMT) != S_IFCHR) {
                return (0);
        }
        if ((statb.st_mode & S_IFMT) != S_IFCHR) {
@@ -63,8 +63,7 @@ setup(dev)
                        return (0);
        }
        if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
                        return (0);
        }
        if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
-               perror(dev);
-               printf("Can't open %s\n", dev);
+               printf("Can't open %s: %s\n", dev, strerror(errno));
                return (0);
        }
        if (preen == 0)
                return (0);
        }
        if (preen == 0)
@@ -209,7 +208,7 @@ setup(dev)
        }
        if (asblk.b_dirty) {
                bcopy((char *)&sblock, (char *)&altsblock,
        }
        if (asblk.b_dirty) {
                bcopy((char *)&sblock, (char *)&altsblock,
-                       (int)sblock.fs_sbsize);
+                       (size_t)sblock.fs_sbsize);
                flush(fswritefd, &asblk);
        }
        /*
                flush(fswritefd, &asblk);
        }
        /*
@@ -235,18 +234,20 @@ setup(dev)
        bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(short));
        blockmap = calloc((unsigned)bmapsize, sizeof (char));
        if (blockmap == NULL) {
        bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(short));
        blockmap = calloc((unsigned)bmapsize, sizeof (char));
        if (blockmap == NULL) {
-               printf("cannot alloc %d bytes for blockmap\n", bmapsize);
+               printf("cannot alloc %u bytes for blockmap\n",
+                   (unsigned)bmapsize);
                goto badsb;
        }
        statemap = calloc((unsigned)(maxino + 1), sizeof(char));
        if (statemap == NULL) {
                goto badsb;
        }
        statemap = calloc((unsigned)(maxino + 1), sizeof(char));
        if (statemap == NULL) {
-               printf("cannot alloc %d bytes for statemap\n", maxino + 1);
+               printf("cannot alloc %u bytes for statemap\n",
+                   (unsigned)(maxino + 1));
                goto badsb;
        }
        lncntp = (short *)calloc((unsigned)(maxino + 1), sizeof(short));
        if (lncntp == NULL) {
                goto badsb;
        }
        lncntp = (short *)calloc((unsigned)(maxino + 1), sizeof(short));
        if (lncntp == NULL) {
-               printf("cannot alloc %d bytes for lncntp\n", 
-                   (maxino + 1) * sizeof(short));
+               printf("cannot alloc %u bytes for lncntp\n", 
+                   (unsigned)(maxino + 1) * sizeof(short));
                goto badsb;
        }
        numdirs = sblock.fs_cstotal.cs_ndir;
                goto badsb;
        }
        numdirs = sblock.fs_cstotal.cs_ndir;
@@ -257,8 +258,8 @@ setup(dev)
        inphead = (struct inoinfo **)calloc((unsigned)numdirs,
            sizeof(struct inoinfo *));
        if (inpsort == NULL || inphead == NULL) {
        inphead = (struct inoinfo **)calloc((unsigned)numdirs,
            sizeof(struct inoinfo *));
        if (inpsort == NULL || inphead == NULL) {
-               printf("cannot alloc %d bytes for inphead\n", 
-                   numdirs * sizeof(struct inoinfo *));
+               printf("cannot alloc %u bytes for inphead\n", 
+                   (unsigned)numdirs * sizeof(struct inoinfo *));
                goto badsb;
        }
        bufinit();
                goto badsb;
        }
        bufinit();
@@ -432,8 +433,7 @@ getdisklabel(s, fd)
        if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
                if (s == NULL)
                        return ((struct disklabel *)NULL);
        if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
                if (s == NULL)
                        return ((struct disklabel *)NULL);
-               pwarn("");
-               perror("ioctl (GDINFO)");
+               pwarn("ioctl (GCINFO): %s\n", strerror(errno));
                errexit("%s: can't read disk label\n", s);
        }
        return (&lab);
                errexit("%s: can't read disk label\n", s);
        }
        return (&lab);
index dcc69b3..d8e2b36 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utilities.c        5.27 (Berkeley) %G%";
+static char sccsid[] = "@(#)utilities.c        5.28 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -14,12 +14,13 @@ static char sccsid[] = "@(#)utilities.c     5.27 (Berkeley) %G%";
 #include <ufs/fs.h>
 #include <ufs/dir.h>
 #include <stdio.h>
 #include <ufs/fs.h>
 #include <ufs/dir.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <ctype.h>
 #include "fsck.h"
 
 long   diskreads, totalreads;  /* Disk cache statistics */
 long   lseek();
 #include <ctype.h>
 #include "fsck.h"
 
 long   diskreads, totalreads;  /* Disk cache statistics */
 long   lseek();
-char   *malloc();
 
 ftypeok(dp)
        struct dinode *dp;
 
 ftypeok(dp)
        struct dinode *dp;
@@ -143,7 +144,7 @@ foundit:
        return (bp);
 }
 
        return (bp);
 }
 
-struct bufarea *
+void
 getblk(bp, blk, size)
        register struct bufarea *bp;
        daddr_t blk;
 getblk(bp, blk, size)
        register struct bufarea *bp;
        daddr_t blk;
@@ -152,14 +153,13 @@ getblk(bp, blk, size)
        daddr_t dblk;
 
        dblk = fsbtodb(&sblock, blk);
        daddr_t dblk;
 
        dblk = fsbtodb(&sblock, blk);
-       if (bp->b_bno == dblk)
-               return (bp);
-       flush(fswritefd, bp);
-       diskreads++;
-       bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size);
-       bp->b_bno = dblk;
-       bp->b_size = size;
-       return (bp);
+       if (bp->b_bno != dblk) {
+               flush(fswritefd, bp);
+               diskreads++;
+               bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size);
+               bp->b_bno = dblk;
+               bp->b_size = size;
+       }
 }
 
 flush(fd, bp)
 }
 
 flush(fd, bp)
@@ -224,8 +224,8 @@ ckfini()
                errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt);
        pbp = pdirbp = (struct bufarea *)0;
        if (debug)
                errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt);
        pbp = pdirbp = (struct bufarea *)0;
        if (debug)
-               printf("cache missed %d of %d (%d%%)\n", diskreads,
-                   totalreads, diskreads * 100 / totalreads);
+               printf("cache missed %ld of %ld (%d%%)\n", diskreads,
+                   totalreads, (int)(diskreads * 100 / totalreads));
        (void)close(fsreadfd);
        (void)close(fswritefd);
 }
        (void)close(fsreadfd);
        (void)close(fswritefd);
 }
@@ -247,17 +247,17 @@ bread(fd, buf, blk, size)
        if (lseek(fd, blk * dev_bsize, 0) < 0)
                rwerror("SEEK", blk);
        errs = 0;
        if (lseek(fd, blk * dev_bsize, 0) < 0)
                rwerror("SEEK", blk);
        errs = 0;
-       bzero(buf, (int)size);
+       bzero(buf, (size_t)size);
        printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
        for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
                if (read(fd, cp, (int)secsize) < 0) {
        printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
        for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
                if (read(fd, cp, (int)secsize) < 0) {
-                       lseek(fd, blk * dev_bsize + i + secsize, 0);
+                       (void)lseek(fd, blk * dev_bsize + i + secsize, 0);
                        if (secsize != dev_bsize && dev_bsize != 1)
                        if (secsize != dev_bsize && dev_bsize != 1)
-                               printf(" %d (%d),",
+                               printf(" %ld (%ld),",
                                    (blk * dev_bsize + i) / secsize,
                                    blk + i / dev_bsize);
                        else
                                    (blk * dev_bsize + i) / secsize,
                                    blk + i / dev_bsize);
                        else
-                               printf(" %d,", blk + i / dev_bsize);
+                               printf(" %ld,", blk + i / dev_bsize);
                        errs++;
                }
        }
                        errs++;
                }
        }
@@ -288,8 +288,8 @@ bwrite(fd, buf, blk, size)
        printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
        for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
                if (write(fd, cp, (int)dev_bsize) < 0) {
        printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
        for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
                if (write(fd, cp, (int)dev_bsize) < 0) {
-                       lseek(fd, blk * dev_bsize + i + dev_bsize, 0);
-                       printf(" %d,", blk + i / dev_bsize);
+                       (void)lseek(fd, blk * dev_bsize + i + dev_bsize, 0);
+                       printf(" %ld,", blk + i / dev_bsize);
                }
        printf("\n");
        return;
                }
        printf("\n");
        return;
@@ -336,7 +336,7 @@ freeblk(blkno, frags)
 
        idesc.id_blkno = blkno;
        idesc.id_numfrags = frags;
 
        idesc.id_blkno = blkno;
        idesc.id_numfrags = frags;
-       pass4check(&idesc);
+       (void)pass4check(&idesc);
 }
 
 /*
 }
 
 /*
@@ -352,7 +352,7 @@ getpathname(namebuf, curdir, ino)
        extern int findname();
 
        if (statemap[curdir] != DSTATE && statemap[curdir] != DFOUND) {
        extern int findname();
 
        if (statemap[curdir] != DSTATE && statemap[curdir] != DFOUND) {
-               strcpy(namebuf, "?");
+               (void)strcpy(namebuf, "?");
                return;
        }
        bzero((char *)&idesc, sizeof(struct inodesc));
                return;
        }
        bzero((char *)&idesc, sizeof(struct inodesc));
@@ -380,15 +380,15 @@ getpathname(namebuf, curdir, ino)
                cp -= len;
                if (cp < &namebuf[MAXNAMLEN])
                        break;
                cp -= len;
                if (cp < &namebuf[MAXNAMLEN])
                        break;
-               bcopy(namebuf, cp, len);
+               bcopy(namebuf, cp, (size_t)len);
                *--cp = '/';
                ino = idesc.id_number;
        }
        if (ino != ROOTINO) {
                *--cp = '/';
                ino = idesc.id_number;
        }
        if (ino != ROOTINO) {
-               strcpy(namebuf, "?");
+               (void)strcpy(namebuf, "?");
                return;
        }
                return;
        }
-       bcopy(cp, namebuf, &namebuf[MAXPATHLEN] - cp);
+       bcopy(cp, namebuf, (size_t)(&namebuf[MAXPATHLEN] - cp));
 }
 
 void
 }
 
 void