Don't cast the return from calloc()
[openafs.git] / src / vfsck / utilities.c
index b247f2e..19f6dc5 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
+#ifdef AFS_HPUX_ENV
+/* We need the old directory type headers (included below), so don't include
+ * the normal dirent.h, or it will conflict. */
+# undef HAVE_DIRENT_H
+# include <sys/inode.h>
+# define       LONGFILENAMES   1
+# include <sys/sysmacros.h>
+# include <sys/ino.h>
+# include <sys/signal.h>
+# define       DIRSIZ_MACRO
+# ifdef HAVE_USR_OLD_USR_INCLUDE_NDIR_H
+#  include </usr/old/usr/include/ndir.h>
+# else
+#  include <ndir.h>
+# endif
+#endif
+
+#include <roken.h>
+
+#include <ctype.h>
 
-#include <sys/param.h>
 #define VICE                   /* allow us to put our changes in at will */
-#include <sys/time.h>
 #ifdef AFS_OSF_ENV
 #include <sys/vnode.h>
 #include <sys/mount.h>
@@ -39,9 +55,6 @@ RCSID
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef   AFS_SUN5_ENV
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
 #include <sys/fs/ufs_inode.h>
 #include <sys/fs/ufs_fs.h>
 #define _KERNEL
@@ -55,29 +68,15 @@ RCSID
 #endif
 #else /* AFS_VFSINCL_ENV */
 #include <sys/inode.h>
-#ifdef AFS_HPUX_ENV
-#include <ctype.h>
-#define        LONGFILENAMES   1
-#include <sys/sysmacros.h>
-#include <sys/ino.h>
-#include <sys/signal.h>
-#define        DIRSIZ_MACRO
-#include <ndir.h>
-#else
+#ifndef        AFS_HPUX_ENV
 #include <sys/dir.h>
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_OSF_ENV */
 
-#include <stdio.h>
-#include <ctype.h>
 #include "fsck.h"
 
-#if    defined(AFS_HPUX101_ENV)
-#include <unistd.h>
-#endif
-
 #if    defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV)
 #define AFS_NEWCG_ENV
 #else
@@ -88,8 +87,7 @@ long diskreads, totalreads;   /* Disk cache statistics */
 #if    !defined(AFS_HPUX101_ENV)
 long lseek();
 #endif
-char *malloc();
-#if    defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV)
+#if    defined(AFS_SUN_ENV)
 extern int iscorrupt;
 #endif
 #ifdef AFS_SUN_ENV
@@ -98,7 +96,6 @@ extern int isdirty;
 #ifdef AFS_SUN5_ENV
 #include <sys/mntent.h>
 #include <sys/mnttab.h>
-#include <sys/stat.h>
 #include <sys/vfstab.h>
 
 offset_t llseek();
@@ -149,7 +146,7 @@ reply(question)
     printf("\n");
     if (!persevere && (nflag || fswritefd < 0)) {
        printf("%s? no\n\n", question);
-#if    defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV)
+#if    defined(AFS_SUN_ENV)
        iscorrupt = 1;          /* known to be corrupt */
 #endif
        return (0);
@@ -172,7 +169,7 @@ reply(question)
 #ifdef AFS_HPUX_ENV
     fixed = 0;
 #endif
-#if    defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV)
+#if    defined(AFS_SUN_ENV)
     iscorrupt = 1;             /* known to be corrupt */
 #endif
     return (0);
@@ -183,7 +180,7 @@ reply(question)
  */
 bufinit()
 {
-    register struct bufarea *bp;
+    struct bufarea *bp;
     long bufcnt, i;
     char *bufp;
 
@@ -225,7 +222,7 @@ getdatablk(blkno, size)
      daddr_t blkno;
      long size;
 {
-    register struct bufarea *bp;
+    struct bufarea *bp;
 
     for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
        if (bp->b_bno == fsbtodb(&sblock, blkno))
@@ -251,7 +248,7 @@ getdatablk(blkno, size)
 
 struct bufarea *
 getblk(bp, blk, size)
-     register struct bufarea *bp;
+     struct bufarea *bp;
      daddr_t blk;
      long size;
 {
@@ -270,9 +267,9 @@ getblk(bp, blk, size)
 
 flush(fd, bp)
      int fd;
-     register struct bufarea *bp;
+     struct bufarea *bp;
 {
-    register int i, j;
+    int i, j;
     caddr_t sip;
     long size;
 
@@ -282,9 +279,6 @@ flush(fd, bp)
        pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n",
               (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
               bp->b_bno);
-#ifdef AFS_DEC_ENV
-       iscorrupt = 1;
-#endif
     }
     bp->b_dirty = 0;
     bp->b_errs = 0;
@@ -309,7 +303,7 @@ flush(fd, bp)
               fsbtodb(&sblock, sblock.fs_csaddr));
     }
 #else
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
     sip = (caddr_t) sblock.fs_u.fs_csp;
     for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
        size =
@@ -326,7 +320,7 @@ flush(fd, bp)
               sblock.fs_cssize - i <
               sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize);
     }
-#endif /* AFS_SUN56_ENV */
+#endif /* AFS_SUN5_ENV */
 #endif /* AFS_HPUX101_ENV */
 }
 
@@ -344,7 +338,7 @@ rwerror(mesg, blk)
 
 ckfini()
 {
-    register struct bufarea *bp, *nbp;
+    struct bufarea *bp, *nbp;
     int cnt = 0;
 
     flush(fswritefd, &sblk);
@@ -370,7 +364,7 @@ ckfini()
        flush(fswritefd, bp);
        nbp = bp->b_prev;
        free(bp->b_un.b_buf);
-       free((char *)bp);
+       free(bp);
     }
 #ifdef AFS_SUN5_ENVX
     pbp = pdirbp = NULL;
@@ -537,7 +531,7 @@ bwrite(fd, buf, blk, size)
 allocblk(frags)
      long frags;
 {
-    register int i, j, k;
+    int i, j, k;
 
     if (frags <= 0 || frags > sblock.fs_frag)
        return (0);
@@ -583,7 +577,7 @@ getpathname(namebuf, curdir, ino)
      ino_t curdir, ino;
 {
     int len;
-    register char *cp;
+    char *cp;
     struct inodesc idesc;
     extern int findname();
 
@@ -591,7 +585,7 @@ getpathname(namebuf, curdir, ino)
        strcpy(namebuf, "?");
        return;
     }
-    memset((char *)&idesc, 0, sizeof(struct inodesc));
+    memset(&idesc, 0, sizeof(struct inodesc));
     idesc.id_type = DATA;
     cp = &namebuf[BUFSIZ - 1];
     *cp = '\0';
@@ -676,7 +670,7 @@ voidquit()
  * determine whether an inode should be fixed.
  */
 dofix(idesc, msg)
-     register struct inodesc *idesc;
+     struct inodesc *idesc;
      char *msg;
 {
 
@@ -817,7 +811,7 @@ updateclean()
     unsigned int size;
     unsigned int bno;
     unsigned int fsclean;
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
     offset_t sblkoff;
 #endif
 
@@ -868,7 +862,7 @@ updateclean()
     /* read private copy of superblock, update clean flag, and write it */
     bno = sblk.b_bno;
     size = sblk.b_size;
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
     sblkoff = (OFF_T) (bno) << DEV_BSHIFT;
     if (llseek(fsreadfd, sblkoff, 0) == -1)
        return;
@@ -887,7 +881,7 @@ updateclean()
     fs_set_state(cleanbuf.b_un.b_fs, fs_get_state(&sblock));
 #endif
     cleanbuf.b_un.b_fs->fs_time = sblock.fs_time;
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
     if (llseek(fswritefd, sblkoff, 0) == -1)
        return;
 #else
@@ -930,11 +924,11 @@ printclean()
 }
 #endif
 
-#ifdef AFS_SUN52_ENV
+#ifdef AFS_SUN5_ENV
 char *
 hasvfsopt(vfs, opt)
-     register struct vfstab *vfs;
-     register char *opt;
+     struct vfstab *vfs;
+     char *opt;
 {
     char *f, *opts;
     static char *tmpopts;
@@ -942,7 +936,7 @@ hasvfsopt(vfs, opt)
     if (vfs->vfs_mntopts == NULL)
        return (NULL);
     if (tmpopts == 0) {
-       tmpopts = (char *)calloc(256, sizeof(char));
+       tmpopts = calloc(256, sizeof(char));
        if (tmpopts == 0)
            return (0);
     }
@@ -1021,7 +1015,6 @@ mounted(name)
 #if    defined(AFS_HPUX101_ENV)
 
 #include "libfs.h"
-#include <sys/stat.h>
 #include <sys/fcntl.h>
 
 int seek_options;