Don't cast the return from calloc()
[openafs.git] / src / vfsck / setup.c
index 4db9fd8..5a3cd12 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <roken.h>
+
+#include <ctype.h>
 
-#include <stdio.h>
-#include <string.h>
 #define VICE
 
 #if    defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV)
@@ -35,8 +36,6 @@ extern vfscklogprintf();
 #endif
 
 #define DKTYPENAMES
-#include <sys/param.h>
-#include <sys/time.h>
 
 #ifdef AFS_OSF_ENV
 #include <sys/vnode.h>
@@ -48,13 +47,10 @@ extern vfscklogprintf();
 #include <ufs/dir.h>
 #undef _KERNEL
 #undef _BSD
-#include <stdio.h>
 #else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef   AFS_SUN5_ENV
-#include <stdio.h>
-#include <unistd.h>
 #include <sys/fs/ufs_inode.h>
 #include <sys/fs/ufs_fs.h>
 #define _KERNEL
@@ -68,7 +64,6 @@ extern vfscklogprintf();
 #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>
@@ -77,10 +72,7 @@ extern vfscklogprintf();
 #endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_OSF_ENV */
 
-#include <sys/stat.h>
-#include <sys/ioctl.h>
 #include <sys/file.h>
-#include <ctype.h>
 #ifdef AFS_SUN5_ENV
 #include <sys/mntent.h>
 #include <sys/vfstab.h>
@@ -98,7 +90,7 @@ struct bufarea *pbp;
 /*
  * The size of a cylinder group is calculated by CGSIZE. The maximum size
  * is limited by the fact that cylinder groups are at most one block.
- * Its size is derived from the size of the maps maintained in the 
+ * Its size is derived from the size of the maps maintained in the
  * cylinder group and the (struct cg) size.
  */
 #define CGSIZE(fs) \
@@ -108,7 +100,6 @@ struct bufarea *pbp;
     /* inode map */    howmany((fs)->fs_ipg, NBBY) + \
     /* block map */    howmany((fs)->fs_cpg * (fs)->fs_spc / NSPF(fs), NBBY))
 
-char *malloc(), *calloc();
 struct disklabel *getdisklabel();
 
 setup(dev)
@@ -205,7 +196,7 @@ setup(dev)
      * The rules are:
      *      1) if nflag is set, it's pretty safe to fsck the target dev
      *      2) if the target device is a swap, exit
-     *      3) if hotroot is set, and "-F" is not specified prompt the 
+     *      3) if hotroot is set, and "-F" is not specified prompt the
      *              user and wait for reply
      *      4) if the target is a mounted file system, and "-F" is not
      *              specified, prompt the user and wait for reply
@@ -482,7 +473,7 @@ setup(dev)
      * read in the summary info.
      */
     asked = 0;
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
     {
        caddr_t sip;
        sip = calloc(1, sblock.fs_cssize);
@@ -503,10 +494,10 @@ setup(dev)
            sip += size;
        }
     }
-#else /* AFS_SUN56_ENV */
+#else /* AFS_SUN5_ENV */
 #if     defined(AFS_HPUX110_ENV)
     size = fragroundup(&sblock, sblock.fs_cssize);
-    sblock.fs_csp = (struct csum *)calloc(1, (unsigned)size);
+    sblock.fs_csp = calloc(1, (unsigned)size);
     if ((bread
         (fsreadfd, (char *)sblock.fs_csp, fsbtodb(&sblock, sblock.fs_csaddr),
          size) != 0) && !asked) {
@@ -526,7 +517,7 @@ setup(dev)
            sblock.fs_cssize - i <
            sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize;
 #endif /* AFS_HPUX101_ENV */
-       sblock.fs_csp[j] = (struct csum *)calloc(1, (unsigned)size);
+       sblock.fs_csp[j] = calloc(1, (unsigned)size);
        if (bread
            (fsreadfd, (char *)sblock.fs_csp[j],
             fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
@@ -542,7 +533,7 @@ setup(dev)
        }
     }
 #endif /* else AFS_HPUX110_ENV */
-#endif /* else AFS_SUN56_ENV */
+#endif /* else AFS_SUN5_ENV */
 
 #if    defined(AFS_SUN_ENV) && !defined(AFS_SUN3_ENV)
     /*
@@ -583,7 +574,7 @@ setup(dev)
        msgprintf("cannot alloc %d bytes for statemap\n", maxino + 1);
        goto badsb;
     }
-    lncntp = (short *)calloc((unsigned)(maxino + 1), sizeof(short));
+    lncntp = calloc((unsigned)(maxino + 1), sizeof(short));
     if (lncntp == NULL) {
        msgprintf("cannot alloc %d bytes for lncntp\n",
                  (maxino + 1) * sizeof(short));
@@ -699,14 +690,14 @@ readsb(listerr)
     altsblock.fs_optim = sblock.fs_optim;
     altsblock.fs_rotdelay = sblock.fs_rotdelay;
     altsblock.fs_maxbpg = sblock.fs_maxbpg;
-#if    !defined(__alpha) && !defined(AFS_SUN56_ENV)
+#if    !defined(__alpha) && !defined(AFS_SUN5_ENV)
 #if !defined(AFS_HPUX110_ENV)
     /* HPUX110 will use UpdateAlternateSuper() below */
     memcpy((char *)altsblock.fs_csp, (char *)sblock.fs_csp,
           sizeof sblock.fs_csp);
 #endif /* ! AFS_HPUX110_ENV */
 #endif /* ! __alpha */
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
     memcpy((char *)altsblock.fs_u.fs_csp_pad, (char *)sblock.fs_u.fs_csp_pad,
           sizeof(sblock.fs_u.fs_csp_pad));
 #endif
@@ -739,7 +730,7 @@ readsb(listerr)
        if (memcmp
            ((char *)&sblock.fs_blank[0], (char *)&altsblock.fs_blank[0],
             MAXCSBUFS * sizeof(int))) {
-           memset((char *)sblock.fs_blank, 0, sizeof(sblock.fs_blank));
+           memset(sblock.fs_blank, 0, sizeof(sblock.fs_blank));
        } else {
 #endif /* __alpha */
            badsb(listerr,
@@ -774,7 +765,7 @@ badsb(listerr, s)
 calcsb(dev, devfd, fs)
      char *dev;
      int devfd;
-     register struct fs *fs;
+     struct fs *fs;
 {
     return 0;
 }
@@ -832,7 +823,7 @@ is_swap(devno)
      dev_t devno;
 {
     struct pst_swapinfo pst[PS_BURST];
-    register struct pst_swapinfo *psp = &pst[0];
+    struct pst_swapinfo *psp = &pst[0];
     int idx = 0, count, match = 0;
 
     while ((count = PSTAT(psp, PS_BURST, idx) != 0)) {
@@ -929,8 +920,8 @@ getline(fp, loc, maxlen)
      FILE *fp;
      char *loc;
 {
-    register n;
-    register char *p, *lastloc;
+    int n;
+    char *p, *lastloc;
 
     p = loc;
     lastloc = &p[maxlen - 1];
@@ -966,7 +957,7 @@ freply(s)
 
 #if   defined(AFS_HPUX110_ENV)
 /*
- *  Refer to function compare_sblocks() in HP's fsck.c 
+ *  Refer to function compare_sblocks() in HP's fsck.c
  *
  *  DESCRIPTION:
  *     This routine will compare the primary superblock (PRIM_SBLOCK) to the