vol, volser, and viced type fixes
authorAndrew Deason <adeason@sinenomine.net>
Thu, 6 May 2010 20:40:36 +0000 (15:40 -0500)
committerRuss Allbery <rra@stanford.edu>
Tue, 25 May 2010 03:56:05 +0000 (20:56 -0700)
Correct many uses of incorrect types for file offsets, sizes, etc. in
the volume server, fileserver, and the volume package.

Thanks to Tom Keiser who pointed out the incorrect types and suggested
solutions.

Change-Id: If4aedfe0cc06d05b3775069ae1285d4c330976cd
Reviewed-on: http://gerrit.openafs.org/1920
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Russ Allbery <rra@stanford.edu>

14 files changed:
src/viced/afsfileprocs.c
src/viced/physio.c
src/vol/ihandle.c
src/vol/listinodes.c
src/vol/namei_ops.c
src/vol/physio.c
src/vol/vnode.c
src/vol/vol-info.c
src/vol/vol-salvage.c
src/volser/dumpstuff.c
src/volser/physio.c
src/volser/vol-dump.c
src/volser/vol_split.c
src/volser/volprocs.c

index ec9eea6..6b524d4 100644 (file)
@@ -1106,13 +1106,13 @@ RXStore_AccessList(Vnode * targetptr, struct AFSOpaque *AccessList)
 #define        COPYBUFFSIZE    8192
 #define MAXFSIZE (~(afs_fsize_t) 0)
 static int
-CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_fsize_t off, afs_fsize_t len)
+CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_foff_t off, afs_fsize_t len)
 {
     Inode ino, nearInode;
-    int rdlen;
-    int wrlen;
+    ssize_t rdlen;
+    ssize_t wrlen;
     register afs_fsize_t size;
-    register int length;
+    size_t length;
     char *buff;
     int rc;                    /* return code */
     IHandle_t *newH;           /* Use until finished copying, then cp to vnode. */
@@ -1180,7 +1180,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_fsize_t off, afs_fsize_t len
            length = COPYBUFFSIZE;
            size -= COPYBUFFSIZE;
        } else {
-           length = (int)size;
+           length = size;
            size = 0;
        }
        rdlen = FDH_READ(targFdP, buff, length);
@@ -1216,10 +1216,14 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_fsize_t off, afs_fsize_t len
                free(buff);
                return ENOSPC;
            } else {
+               /* length, rdlen, and wrlen may or may not be 64-bits wide;
+                * since we never do any I/O anywhere near 2^32 bytes at a
+                * time, just case to an unsigned int for printing */
+
                ViceLog(0,
                        ("CopyOnWrite failed: volume %u in partition %s  (tried reading %u, read %u, wrote %u, errno %u) volume needs salvage\n",
-                        V_id(volptr), volptr->partition->name, length, rdlen,
-                        wrlen, errno));
+                        V_id(volptr), volptr->partition->name, (unsigned)length, (unsigned)rdlen,
+                        (unsigned)wrlen, errno));
 #if defined(AFS_DEMAND_ATTACH_FS)
                ViceLog(0, ("CopyOnWrite failed: requesting salvage\n"));
 #else
@@ -1258,11 +1262,11 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_fsize_t off, afs_fsize_t len
 }                              /*CopyOnWrite */
 
 static int
-CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_fsize_t off, afs_fsize_t size) {
+CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_foff_t off, afs_fsize_t size) {
     char *buff = (char *)malloc(COPYBUFFSIZE);
-    register int length;
-    int rdlen;
-    int wrlen;
+    size_t length;
+    ssize_t rdlen;
+    ssize_t wrlen;
     int rc;
 
     FDH_SEEK(targFdP, off, SEEK_SET);
@@ -1274,7 +1278,7 @@ CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_fsize_t off, afs_fsize
            length = COPYBUFFSIZE;
            size -= COPYBUFFSIZE;
        } else {
-           length = (int)size;
+           length = size;
            size = 0;
        }
        rdlen = FDH_READ(targFdP, buff, length);
@@ -4317,7 +4321,8 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *targetptr = 0;      /* vnode of the new link */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     Error errorCode = 0;               /* error code */
-    int len, code = 0;
+    afs_sfsize_t len;
+    int code = 0;
     DirHandle dir;             /* Handle for dir package I/O */
     Volume *volptr = 0;                /* pointer to the volume header */
     struct client *client = 0; /* pointer to client structure */
@@ -4418,7 +4423,7 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     len = strlen((char *) LinkContents);
     code = (len == FDH_WRITE(fdP, (char *) LinkContents, len)) ? 0 : VDISKFULL;
     if (code) 
-       ViceLog(0, ("SAFSS_Symlink FDH_WRITE failed for len=%d, Fid=%u.%d.%d\n", len, OutFid->Volume, OutFid->Vnode, OutFid->Unique));
+       ViceLog(0, ("SAFSS_Symlink FDH_WRITE failed for len=%d, Fid=%u.%d.%d\n", (int)len, OutFid->Volume, OutFid->Vnode, OutFid->Unique));
     FDH_CLOSE(fdP);
     /*
      * Set up and return modified status for the parent dir and new symlink
@@ -6978,7 +6983,6 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     )
 {
     struct timeval StartTime, StopTime;        /* used to calculate file  transfer rates */
-    Error errorCode = 0;               /* Returned error code to caller */
     IHandle_t *ihP;
     FdHandle_t *fdP;
 #ifdef AFS_NT40_ENV
@@ -7060,14 +7064,15 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     tbuffer = AllocSendBuffer();
 #endif /* AFS_NT40_ENV */
     while (Len > 0) {
-       int wlen;
+       size_t wlen;
+       ssize_t nBytes;
        if (Len > optSize)
            wlen = optSize;
        else
-           wlen = (int)Len;
+           wlen = Len;
 #ifdef AFS_NT40_ENV
-       errorCode = FDH_READ(fdP, tbuffer, wlen);
-       if (errorCode != wlen) {
+       nBytes = FDH_READ(fdP, tbuffer, wlen);
+       if (nBytes != wlen) {
            FDH_CLOSE(fdP);
            FreeSendBuffer((struct afs_buffer *)tbuffer);
            VTakeOffline(volptr);
@@ -7075,32 +7080,32 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
                        volptr->hashid));
            return EIO;
        }
-       errorCode = rx_Write(Call, tbuffer, wlen);
+       nBytes = rx_Write(Call, tbuffer, wlen);
 #else /* AFS_NT40_ENV */
-       errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
-       if (errorCode <= 0) {
+       nBytes = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
+       if (nBytes <= 0) {
            FDH_CLOSE(fdP);
            return EIO;
        }
-       wlen = errorCode;
-       errorCode = FDH_READV(fdP, tiov, tnio);
-       if (errorCode != wlen) {
+       wlen = nBytes;
+       nBytes = FDH_READV(fdP, tiov, tnio);
+       if (nBytes != wlen) {
            FDH_CLOSE(fdP);
            VTakeOffline(volptr);
            ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
                        volptr->hashid));
            return EIO;
        }
-       errorCode = rx_Writev(Call, tiov, tnio, wlen);
+       nBytes = rx_Writev(Call, tiov, tnio, wlen);
 #endif /* AFS_NT40_ENV */
 #if FS_STATS_DETAILED
        /*
         * Bump the number of bytes actually sent by the number from this
         * latest iteration
         */
-       (*a_bytesFetchedP) += errorCode;
+       (*a_bytesFetchedP) += nBytes;
 #endif /* FS_STATS_DETAILED */
-       if (errorCode != wlen) {
+       if (nBytes != wlen) {
            FDH_CLOSE(fdP);
 #ifdef AFS_NT40_ENV
            FreeSendBuffer((struct afs_buffer *)tbuffer);
@@ -7221,6 +7226,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
     afs_sfsize_t adjustSize;   /* bytes to call VAdjust... with */
     int linkCount = 0;         /* link count on inode */
     afs_fsize_t CoW_off, CoW_len;
+    ssize_t nBytes;
     FdHandle_t *fdP, *origfdP = NULL;
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 
@@ -7382,9 +7388,11 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        /* Set the file's length; we've already done an lseek to the right
         * spot above.
         */
-       errorCode = FDH_WRITE(fdP, &tlen, 1);
-       if (errorCode != 1)
+       nBytes = FDH_WRITE(fdP, &tlen, 1);
+       if (nBytes != 1) {
+           errorCode = -1;
            goto done;
+       }
        errorCode = FDH_TRUNC(fdP, Pos);
     } else {
        /* have some data to copy */
@@ -7416,11 +7424,11 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
 #endif /* FS_STATS_DETAILED */
            rlen = errorCode;
 #ifdef AFS_NT40_ENV
-           errorCode = FDH_WRITE(fdP, tbuffer, rlen);
+           nBytes = FDH_WRITE(fdP, tbuffer, rlen);
 #else /* AFS_NT40_ENV */
-           errorCode = FDH_WRITEV(fdP, tiov, tnio);
+           nBytes = FDH_WRITEV(fdP, tiov, tnio);
 #endif /* AFS_NT40_ENV */
-           if (errorCode != rlen) {
+           if (nBytes != rlen) {
                errorCode = VDISKFULL;
                break;
            }
index 47d9a8c..fb2e070 100644 (file)
@@ -50,6 +50,7 @@ int
 ReallyRead(DirHandle * file, int block, char *data)
 {
     int code;
+    ssize_t rdlen;
     FdHandle_t *fdP;
 
     fdP = IH_OPEN(file->dirh_handle);
@@ -72,9 +73,9 @@ ReallyRead(DirHandle * file, int block, char *data)
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_READ(fdP, data, PAGESIZE);
-    if (code != PAGESIZE) {
-       if (code < 0)
+    rdlen = FDH_READ(fdP, data, PAGESIZE);
+    if (rdlen != PAGESIZE) {
+       if (rdlen < 0)
            code = errno;
        else
            code = EIO;
@@ -95,7 +96,7 @@ ReallyRead(DirHandle * file, int block, char *data)
 int
 ReallyWrite(DirHandle * file, int block, char *data)
 {
-    afs_int32 count;
+    ssize_t count;
     FdHandle_t *fdP;
 
     fdP = IH_OPEN(file->dirh_handle);
index 8b2f3dc..2ea3fb7 100644 (file)
@@ -676,7 +676,7 @@ stream_write(void *ptr, afs_fsize_t size, afs_fsize_t nitems,
 int
 stream_seek(StreamHandle_t * streamP, afs_foff_t offset, int whence)
 {
-    int rc;
+    ssize_t rc;
     int retval = 0;
 
     if (streamP->str_direction == STREAM_DIRECTION_WRITE
@@ -703,7 +703,7 @@ stream_seek(StreamHandle_t * streamP, afs_foff_t offset, int whence)
 int
 stream_flush(StreamHandle_t * streamP)
 {
-    int rc;
+    ssize_t rc;
     int retval = 0;
 
     if (streamP->str_direction == STREAM_DIRECTION_WRITE
@@ -725,7 +725,7 @@ stream_flush(StreamHandle_t * streamP)
 int
 stream_close(StreamHandle_t * streamP, int reallyClose)
 {
-    int rc;
+    ssize_t rc;
     int retval = 0;
 
     assert(streamP != NULL);
index 7499aa9..cf5578c 100644 (file)
@@ -1390,7 +1390,8 @@ inode_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId)
     char volname[20];
     char headername[16];
     char *name;
-    int fd, err, forcep, len, j, code;
+    int fd, err, forcep, j;
+    ssize_t len, nBytes;
     struct dirent *dp;
     struct DiskPartition64 *partP;
     struct ViceInodeInfo info;
@@ -1478,8 +1479,8 @@ inode_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId)
                        return errno;
                    if (len == 0)
                        break;
-                   code = write(fdP2->fd_fd, buffer, len);
-                   if (code != len)
+                   nBytes = write(fdP2->fd_fd, buffer, len);
+                   if (nBytes != len)
                        return -1;
                }
            }
index b2aefe6..26a0a75 100644 (file)
@@ -834,7 +834,7 @@ namei_copy_on_write(IHandle_t *h)
        char path[259];
        char *buf;
        afs_size_t size;
-       afs_int32 tlen;
+       ssize_t tlen;
        
        fdP = IH_OPEN(h);
        if (!fdP)
@@ -1040,7 +1040,7 @@ GetFreeTag(IHandle_t * ih, int vno)
     int col;
     int coldata;
     short row;
-    int code;
+    ssize_t nBytes;
 
 
     fdP = IH_OPEN(ih);
@@ -1058,9 +1058,9 @@ GetFreeTag(IHandle_t * ih, int vno)
        goto badGetFreeTag;
     }
 
-    code = read(fdP->fd_fd, (char *)&row, sizeof(row));
-    if (code != sizeof(row)) {
-       if (code != 0)
+    nBytes = read(fdP->fd_fd, (char *)&row, sizeof(row));
+    if (nBytes != sizeof(row)) {
+       if (nBytes != 0)
            goto badGetFreeTag;
        row = 0;
     }
@@ -1109,7 +1109,7 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked)
     int index;
     unsigned short row;
     int junk;
-    int code = -1;
+    ssize_t nBytes = -1;
 
     namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
 
@@ -1124,9 +1124,9 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked)
     }
 
 
-    code = read(fdP->fd_fd, (char *)&row, sizeof(row));
-    if (code != sizeof(row)) {
-       if (code != 0) {
+    nBytes = read(fdP->fd_fd, (char *)&row, sizeof(row));
+    if (nBytes != sizeof(row)) {
+       if (nBytes != 0) {
            errno = EBADF;
            goto bad_SetLinkCount;
        }
@@ -1149,13 +1149,13 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked)
     }
     FDH_SYNC(fdP);
 
-    code = 0;
+    nBytes = 0;
 
 
   bad_SetLinkCount:
     flock(fdP->fd_fd, LOCK_UN);
 
-    return code;
+    return nBytes;
 }
 
 
index 7679567..8b5845a 100644 (file)
@@ -48,20 +48,21 @@ ReallyRead(DirHandle * file, int block, char *data)
 {
     FdHandle_t *fdP;
     int code;
+    ssize_t nBytes;
     errno = 0;
     fdP = IH_OPEN(file->dirh_handle);
     if (fdP == NULL) {
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, ((afs_foff_t)block) * AFS_PAGESIZE, SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_READ(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
-    if (code != AFS_PAGESIZE) {
-       if (code < 0)
+    nBytes = FDH_READ(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
+    if (nBytes != AFS_PAGESIZE) {
+       if (nBytes < 0)
            code = errno;
        else
            code = EIO;
@@ -79,6 +80,7 @@ ReallyWrite(DirHandle * file, int block, char *data)
     FdHandle_t *fdP;
     extern int VolumeChanged;
     int code;
+    ssize_t nBytes;
 
     errno = 0;
 
@@ -87,14 +89,14 @@ ReallyWrite(DirHandle * file, int block, char *data)
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, ((afs_foff_t)block) * AFS_PAGESIZE, SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_WRITE(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
-    if (code != AFS_PAGESIZE) {
-       if (code < 0)
+    nBytes = FDH_WRITE(fdP, data, (afs_fsize_t) AFS_PAGESIZE);
+    if (nBytes != AFS_PAGESIZE) {
+       if (nBytes < 0)
            code = errno;
        else
            code = EIO;
index 269800a..a5f6957 100644 (file)
@@ -870,7 +870,8 @@ VnLoad(Error * ec, Volume * vp, Vnode * vnp,
 {
     /* vnode not cached */
     Error error;
-    int n, dosalv = 1;
+    int dosalv = 1;
+    ssize_t nBytes;
     IHandle_t *ihP = vp->vnodeIndex[class].handle;
     FdHandle_t *fdP;
 
@@ -896,23 +897,23 @@ VnLoad(Error * ec, Volume * vp, Vnode * vnp,
        Log("VnLoad: can't seek on index file vn=%u\n", Vn_id(vnp));
        *ec = VIO;
        goto error_encountered_nolock;
-    } else if ((n = FDH_READ(fdP, (char *)&vnp->disk, vcp->diskSize))
+    } else if ((nBytes = FDH_READ(fdP, (char *)&vnp->disk, vcp->diskSize))
               != vcp->diskSize) {
        /* Don't take volume off line if the inumber is out of range
         * or the inode table is full. */
-       if (n == BAD_IGET) {
+       if (nBytes == BAD_IGET) {
            Log("VnLoad: bad inumber %s\n",
                PrintInode(NULL, vp->vnodeIndex[class].handle->ih_ino));
            *ec = VIO;
            dosalv = 0;
-       } else if (n == -1 && errno == EIO) {
+       } else if (nBytes == -1 && errno == EIO) {
            /* disk error; salvage */
            Log("VnLoad: Couldn't read vnode %u, volume %u (%s); volume needs salvage\n", Vn_id(vnp), V_id(vp), V_name(vp));
        } else {
            /* vnode is not allocated */
            if (LogLevel >= 5) 
                Log("VnLoad: Couldn't read vnode %u, volume %u (%s); read %d bytes, errno %d\n", 
-                   Vn_id(vnp), V_id(vp), V_name(vp), n, errno);
+                   Vn_id(vnp), V_id(vp), V_name(vp), (int)nBytes, errno);
            *ec = VIO;
            dosalv = 0;
        }
@@ -996,7 +997,8 @@ static void
 VnStore(Error * ec, Volume * vp, Vnode * vnp, 
        struct VnodeClassInfo * vcp, VnodeClass class)
 {
-    int offset, code;
+    ssize_t nBytes;
+    afs_foff_t offset;
     IHandle_t *ihP = vp->vnodeIndex[class].handle;
     FdHandle_t *fdP;
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -1022,13 +1024,13 @@ VnStore(Error * ec, Volume * vp, Vnode * vnp,
        goto error_encountered;
     }
 
-    code = FDH_WRITE(fdP, &vnp->disk, vcp->diskSize);
-    if (code != vcp->diskSize) {
+    nBytes = FDH_WRITE(fdP, &vnp->disk, vcp->diskSize);
+    if (nBytes != vcp->diskSize) {
        /* Don't force volume offline if the inumber is out of
         * range or the inode table is full.
         */
        FDH_REALLYCLOSE(fdP);
-       if (code == BAD_IGET) {
+       if (nBytes == BAD_IGET) {
            Log("VnStore: bad inumber %s\n",
                PrintInode(NULL,
                           vp->vnodeIndex[class].handle->ih_ino));
@@ -1038,7 +1040,7 @@ VnStore(Error * ec, Volume * vp, Vnode * vnp,
            VnChangeState_r(vnp, VN_STATE_ERROR);
 #endif
        } else {
-           Log("VnStore: Couldn't write vnode %u, volume %u (%s) (error %d)\n", Vn_id(vnp), V_id(Vn_volume(vnp)), V_name(Vn_volume(vnp)), code);
+           Log("VnStore: Couldn't write vnode %u, volume %u (%s) (error %d)\n", Vn_id(vnp), V_id(Vn_volume(vnp)), V_name(Vn_volume(vnp)), (int)nBytes);
 #ifdef AFS_DEMAND_ATTACH_FS
            goto error_encountered;
 #else
index e9fc339..b7143f2 100644 (file)
@@ -754,7 +754,9 @@ PrintVnodes(Volume * vp, VnodeClass class)
     int size;
     char *ctime, *atime, *mtime;
     char nfile[50], buffer[256];
-    int total, ofd, len, code, bad = 0;
+    int ofd, bad = 0;
+    afs_foff_t total;
+    ssize_t len;
 
     fdP = IH_OPEN(ih);
     if (fdP == NULL) {
@@ -806,6 +808,7 @@ PrintVnodes(Volume * vp, VnodeClass class)
                }
                total = bad = 0;
                while (1) {
+                   ssize_t nBytes;
                    len = FDH_READ(fdP1, buffer, sizeof(buffer));
                    if (len < 0) {
                        FDH_REALLYCLOSE(fdP1);
@@ -820,8 +823,8 @@ PrintVnodes(Volume * vp, VnodeClass class)
                    }
                    if (len == 0)
                        break;  /* No more input */
-                   code = write(ofd, buffer, len);
-                   if (code != len) {
+                   nBytes = write(ofd, buffer, len);
+                   if (nBytes != len) {
                        FDH_REALLYCLOSE(fdP1);
                        IH_RELEASE(ih1);
                        close(ofd);
@@ -839,8 +842,8 @@ PrintVnodes(Volume * vp, VnodeClass class)
                FDH_REALLYCLOSE(fdP1);
                IH_RELEASE(ih1);
                close(ofd);
-               printf("... Copied inode %s to file %s (%d bytes)\n",
-                      PrintInode(NULL, ino), nfile, total);
+               printf("... Copied inode %s to file %s (%lu bytes)\n",
+                      PrintInode(NULL, ino), nfile, (unsigned long)total);
            }
        } else {
 #if defined(AFS_NAMEI_ENV)
index f513cb9..d0571e8 100644 (file)
@@ -2319,7 +2319,7 @@ SalvageHeader(register struct stuff *sp, struct InodeSummary *isp, int check,
     } header;
     IHandle_t *specH;
     int recreate = 0;
-    afs_int32 code;
+    ssize_t nBytes;
     FdHandle_t *fdP;
 
     if (sp->obsolete)
@@ -2389,8 +2389,8 @@ SalvageHeader(register struct stuff *sp, struct InodeSummary *isp, int check,
            Abort
                ("Internal error: recreating volume header (%s) in check mode\n",
                 sp->description);
-       code = FDH_TRUNC(fdP, 0);
-       if (code == -1)
+       nBytes = FDH_TRUNC(fdP, 0);
+       if (nBytes == -1)
            Abort("Unable to truncate volume header file (%s) (error = %d)\n",
                  sp->description, errno);
 
@@ -2417,11 +2417,11 @@ SalvageHeader(register struct stuff *sp, struct InodeSummary *isp, int check,
                    ("Unable to seek to beginning of volume header file (%s) (errno = %d)\n",
                     sp->description, errno);
            }
-           code =
+           nBytes =
                FDH_WRITE(fdP, (char *)&header.volumeInfo,
                          sizeof(header.volumeInfo));
-           if (code != sizeof(header.volumeInfo)) {
-               if (code < 0)
+           if (nBytes != sizeof(header.volumeInfo)) {
+               if (nBytes < 0)
                    Abort
                        ("Unable to write volume header file (%s) (errno = %d)\n",
                         sp->description, errno);
@@ -2434,9 +2434,9 @@ SalvageHeader(register struct stuff *sp, struct InodeSummary *isp, int check,
                    ("Unable to seek to beginning of volume header file (%s) (errno = %d)\n",
                     sp->description, errno);
            }
-           code = FDH_WRITE(fdP, (char *)&sp->stamp, sizeof(sp->stamp));
-           if (code != sizeof(sp->stamp)) {
-               if (code < 0)
+           nBytes = FDH_WRITE(fdP, (char *)&sp->stamp, sizeof(sp->stamp));
+           if (nBytes != sizeof(sp->stamp)) {
+               if (nBytes < 0)
                    Abort
                        ("Unable to write version stamp in volume header file (%s) (errno = %d)\n",
                         sp->description, errno);
@@ -3059,7 +3059,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
            Log("FOUND suid/sgid file: %s/%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
        if (/* ShowMounts && */ (vnodeEssence->type == vSymlink)
            && !(vnodeEssence->modeBits & 0111)) {
-           int code, size;
+           ssize_t nBytes, size;
            char buf[1025];
            IHandle_t *ihP;
            FdHandle_t *fdP;
@@ -3074,7 +3074,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
            }
            size = FDH_SIZE(fdP);
            if (size < 0) {
-               Log("ERROR %s mount point has invalid size %d, vnode %u\n", dir->vname, size, vnodeNumber);
+               Log("ERROR %s mount point has invalid size %d, vnode %u\n", dir->vname, (int)size, vnodeNumber);
                FDH_REALLYCLOSE(fdP);
                IH_RELEASE(ihP);
                return 0;
@@ -3082,8 +3082,8 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
        
            if (size > 1024)
                size = 1024;
-           code = FDH_READ(fdP, buf, size);
-           if (code == size) {
+           nBytes = FDH_READ(fdP, buf, size);
+           if (nBytes == size) {
                buf[size] = '\0';
                if ( (*buf != '#' && *buf != '%') || buf[strlen(buf)-1] != '.' ) {
                    Log("Volume %u (%s) mount point %s/%s to '%s' invalid, %s to symbolic link\n",
@@ -3096,7 +3096,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
                    dir->name ? dir->name : "??", name, buf);
            } else {
                Log("Volume %s cound not read mount point vnode %u size %d code %d\n",
-                   dir->vname, vnodeNumber, size, code);
+                   dir->vname, vnodeNumber, (int)size, (int)nBytes);
            }
            FDH_REALLYCLOSE(fdP);
            IH_RELEASE(ihP);
@@ -4289,17 +4289,16 @@ CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume)
     char buf[4096];
     IHandle_t *srcH, *destH;
     FdHandle_t *srcFdP, *destFdP;
-    register int n = 0;
+    ssize_t nBytes = 0;
 
     IH_INIT(srcH, device, rwvolume, inode1);
     srcFdP = IH_OPEN(srcH);
     assert(srcFdP != NULL);
     IH_INIT(destH, device, rwvolume, inode2);
     destFdP = IH_OPEN(destH);
-    assert(n != -1);
-    while ((n = FDH_READ(srcFdP, buf, sizeof(buf))) > 0)
-       assert(FDH_WRITE(destFdP, buf, n) == n);
-    assert(n == 0);
+    while ((nBytes = FDH_READ(srcFdP, buf, sizeof(buf))) > 0)
+       assert(FDH_WRITE(destFdP, buf, nBytes) == nBytes);
+    assert(nBytes == 0);
     FDH_REALLYCLOSE(srcFdP);
     FDH_REALLYCLOSE(destFdP);
     IH_RELEASE(srcH);
index 313f26f..ae244a0 100644 (file)
@@ -708,7 +708,9 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
     int code = 0, error = 0;
     afs_int32 pad = 0;
     afs_int32 offset = 0;
-    afs_sfsize_t n, nbytes, howMany, howBig;
+    afs_sfsize_t nbytes, howBig;
+    ssize_t n;
+    size_t howMany;
     afs_foff_t lcode = 0;
     byte *p;
     afs_uint32 hi, lo;
@@ -747,7 +749,7 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
         Log("DumpFile: fstatfs returned error code %d on descriptor %d\n", errno, handleP->fd_fd);
        return VOLSERDUMPERROR;
     }
-    howMany = (afs_sfsize_t) tstatfs.f_bsize;
+    howMany = tstatfs.f_bsize;
 #else
     howMany = status.st_blksize;
 #endif /* AFS_AIX_ENV */
@@ -765,9 +767,9 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
        return VOLSERDUMPERROR;
     }
 
-    p = (unsigned char *)malloc((size_t)howMany);
+    p = malloc(howMany);
     if (!p) {
-       Log("1 Volser: DumpFile: not enough memory to allocate %u bytes\n", howMany);
+       Log("1 Volser: DumpFile: not enough memory to allocate %u bytes\n", (unsigned)howMany);
        return VOLSERDUMPERROR;
     }
 
@@ -776,7 +778,7 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
            howMany = nbytes;
 
        /* Read the data - unless we know we can't */
-       n = (lcode ? 0 : FDH_READ(handleP, p, (size_t)howMany));
+       n = (lcode ? 0 : FDH_READ(handleP, p, howMany));
 
        /* If read any good data and we null padded previously, log the
         * amount that we had null padded.
@@ -824,7 +826,7 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
        }
 
        /* Now write the data out */
-       if (iod_Write(iodp, (char *)p, (size_t)howMany) != howMany)
+       if (iod_Write(iodp, (char *)p, howMany) != howMany)
            error = VOLSERDUMPERROR;
 #ifndef AFS_PTHREAD_ENV
        IOMGR_Poll();
@@ -1510,10 +1512,10 @@ volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag,
                 Error * status)
 {
     afs_int32 code;
-    afs_sfsize_t lcode;
+    ssize_t nBytes;
     afs_fsize_t filesize;
     afs_fsize_t written = 0;
-    register afs_uint32 size = 8192;
+    size_t size = 8192;
     register afs_fsize_t nbytes;
     unsigned char *p;
 
@@ -1550,15 +1552,15 @@ volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag,
            size = nbytes;
 
        if ((code = iod_Read(iodp, (char *) p, size)) != size) {
-           Log("1 Volser: WriteFile: Error reading dump file %d size=%llu nbytes=%u (%d of %u): %s; restore aborted\n", vn, (afs_uintmax_t) filesize, nbytes, code, size, afs_error_message(errno));
+           Log("1 Volser: WriteFile: Error reading dump file %d size=%llu nbytes=%u (%d of %u): %s; restore aborted\n", vn, (afs_uintmax_t) filesize, nbytes, code, (unsigned)size, afs_error_message(errno));
            *status = 3;
            break;
        }
-       lcode = FDH_WRITE(handleP, p, size);
-       if (lcode > 0)
-           written += lcode;
-       if (lcode != size) {
-           Log("1 Volser: WriteFile: Error writing (%d,%u) bytes to vnode %d: %s; restore aborted\n", (int)(lcode>>32), (int)(lcode & 0xffffffff), vn, afs_error_message(errno));
+       nBytes = FDH_WRITE(handleP, p, size);
+       if (nBytes > 0)
+           written += nBytes;
+       if (nBytes != size) {
+           Log("1 Volser: WriteFile: Error writing (%d,%u) bytes to vnode %d: %s; restore aborted\n", (int)(nBytes>>32), (int)(nBytes & 0xffffffff), vn, afs_error_message(errno));
            *status = 4;
            break;
        }
index 89980bc..620ed78 100644 (file)
@@ -41,20 +41,21 @@ ReallyRead(DirHandle * file, int block, char *data)
 {
     FdHandle_t *fdP;
     int code;
+    ssize_t nBytes;
     errno = 0;
     fdP = IH_OPEN(file->dirh_handle);
     if (fdP == NULL) {
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, ((afs_foff_t)block) * AFS_PAGESIZE, SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_READ(fdP, data, AFS_PAGESIZE);
-    if (code != AFS_PAGESIZE) {
-       if (code < 0)
+    nBytes = FDH_READ(fdP, data, AFS_PAGESIZE);
+    if (nBytes != AFS_PAGESIZE) {
+       if (nBytes < 0)
            code = errno;
        else
            code = EIO;
@@ -72,6 +73,7 @@ ReallyWrite(DirHandle * file, int block, char *data)
     FdHandle_t *fdP;
     extern int VolumeChanged;
     int code;
+    ssize_t nBytes;
 
     errno = 0;
 
@@ -80,14 +82,14 @@ ReallyWrite(DirHandle * file, int block, char *data)
        code = errno;
        return code;
     }
-    if (FDH_SEEK(fdP, block * AFS_PAGESIZE, SEEK_SET) < 0) {
+    if (FDH_SEEK(fdP, ((afs_foff_t)block) * AFS_PAGESIZE, SEEK_SET) < 0) {
        code = errno;
        FDH_REALLYCLOSE(fdP);
        return code;
     }
-    code = FDH_WRITE(fdP, data, AFS_PAGESIZE);
-    if (code != AFS_PAGESIZE) {
-       if (code < 0)
+    nBytes = FDH_WRITE(fdP, data, AFS_PAGESIZE);
+    if (nBytes != AFS_PAGESIZE) {
+       if (nBytes < 0)
            code = errno;
        else
            code = EIO;
index c53ad37..cc09cb7 100644 (file)
@@ -560,7 +560,9 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v
     int code = 0, failed_seek = 0, failed_write = 0;
     afs_int32 pad = 0;
     afs_int32 offset = 0;
-    afs_sfsize_t n, nbytes, howMany, howBig;
+    afs_sfsize_t nbytes, howBig;
+    ssize_t n;
+    size_t howMany;
     byte *p;
     afs_uint32 hi, lo;
 #ifndef AFS_NT40_ENV
@@ -642,7 +644,7 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v
         */
        if (n < howMany) {
 
-               if (verbose) fprintf(stderr, "  read %u instead of %u bytes.\n", n, howMany);
+               if (verbose) fprintf(stderr, "  read %u instead of %u bytes.\n", (unsigned)n, (unsigned)howMany);
 
            /* Record the read error */
            if (n < 0) {
index 186772a..e60ad70 100644 (file)
@@ -281,7 +281,7 @@ copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh)
     FDH_SEEK(outfdP, 0, 0);
     size = FDH_SIZE(infdP);
     while (size) {
-       afs_int32 tlen;
+       size_t tlen;
         tlen = size > 2048 ? 2048 : size;
         if (FDH_READ(infdP, tbuf, tlen) != tlen) {
                    sprintf(m->line, "Couldn't read directory %u.%u.%u\n", 
@@ -528,7 +528,8 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     IHandle_t *h;
     struct VnodeDiskObject vnode;
     FdHandle_t *fdP, *fdP2;
-    afs_uint64 offset, size;
+    afs_uint64 size;
+    afs_foff_t offset;
     afs_int32 class = vSmall;
     struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
 #if defined(NEARINODE_HINT) && !defined(AFS_NAMEI_ENV)
index 8de0c41..b55af40 100644 (file)
@@ -313,8 +313,9 @@ ViceCreateRoot(Volume *vp)
     struct VnodeClassInfo *vcp = &VnodeClassInfo[vLarge];
     IHandle_t *h;
     FdHandle_t *fdP;
-    int code;
     afs_fsize_t length;
+    ssize_t nBytes;
+    afs_foff_t off;
 
     vnode = (struct VnodeDiskObject *)malloc(SIZEOF_LARGEDISKVNODE);
     if (!vnode)
@@ -374,10 +375,10 @@ ViceCreateRoot(Volume *vp)
            vp->vnodeIndex[vLarge].handle->ih_ino);
     fdP = IH_OPEN(h);
     assert(fdP != NULL);
-    code = FDH_SEEK(fdP, vnodeIndexOffset(vcp, 1), SEEK_SET);
-    assert(code >= 0);
-    code = FDH_WRITE(fdP, vnode, SIZEOF_LARGEDISKVNODE);
-    assert(code == SIZEOF_LARGEDISKVNODE);
+    off = FDH_SEEK(fdP, vnodeIndexOffset(vcp, 1), SEEK_SET);
+    assert(off >= 0);
+    nBytes = FDH_WRITE(fdP, vnode, SIZEOF_LARGEDISKVNODE);
+    assert(nBytes == SIZEOF_LARGEDISKVNODE);
     FDH_REALLYCLOSE(fdP);
     IH_RELEASE(h);
     VNDISK_GET_LEN(length, vnode);