Add braces to empty conditional blocks
[openafs.git] / src / butm / file_tm.c
index 68a8f20..fd4c8d7 100644 (file)
@@ -204,8 +204,14 @@ ForkIoctl(usd_handle_t fd, int op, int count)
        /* do the ioctl call */
        ioctl_rc = USD_IOCTL(fd, USD_IOCTL_TAPEOPERATION, (void *)&tapeop);
 
-       /* send the return code back to the parent */
-       write(pipefd[1], &ioctl_rc, sizeof(int));
+       /*
+        * Send the return code back to the parent.
+        * If this fails, there's nothing we can do, but we must test
+        * it in order to avoid complier warnings on some platforms.
+        */
+       if (write(pipefd[1], &ioctl_rc, sizeof(int)) < 0) {
+           /* don't care */
+       }
 
        exit(0);
     } else {                   /* parent process */
@@ -327,8 +333,14 @@ ForkOpen(char *device)
            USD_CLOSE(fd);
        }
 
-       /* send the return code back to the parent */
-       write(pipefd[1], &open_rc, sizeof(open_rc));
+       /*
+        * Send the return code back to the parent.
+        * If this fails, there's nothing we can do, but we must test
+        * it in order to avoid complier warnings on some platforms.
+        */
+       if (write(pipefd[1], &open_rc, sizeof(open_rc)) < 0) {
+           /* don't care */
+       }
 
        exit(0);
     } else {                   /* parent process */
@@ -452,15 +464,28 @@ ForkClose(usd_handle_t fd)
            }
        }
 
-       /* the parent writes the control pipe after it closes the device */
-       read(ctlpipe[0], &close_rc, sizeof(int));
+       /*
+        * The parent writes the control pipe after it closes the device.
+        * We don't actually care about the read; we're just using it to
+        * block until the parent is ready.  But we must do something
+        * with the result, to avoid complier warnings on some platforms.
+        */
+       if (read(ctlpipe[0], &close_rc, sizeof(int)) < 0) {
+           /* don't care */
+       }
        close(ctlpipe[0]);
 
        /* do the close */
        close_rc = USD_CLOSE(fd);
 
-       /* send the return code back to the parent */
-       write(pipefd[1], &close_rc, sizeof(int));
+       /*
+        * Send the return code back to the parent.
+        * If this fails, there's nothing we can do, but we must test
+        * it in order to avoid complier warnings on some platforms.
+        */
+       if (write(pipefd[1], &close_rc, sizeof(int)) < 0) {
+           /* don't care */
+       }
 
        exit(0);
     } else {                   /* parent process */
@@ -573,10 +598,9 @@ static int
 Rewind(usd_handle_t fid)
 {
     if (isafile) {
-       afs_hyper_t startOff, stopOff;
-       hzero(startOff);
+       afs_int64 stopOff;
 
-       return (USD_SEEK(fid, startOff, SEEK_SET, &stopOff));
+       return (USD_SEEK(fid, 0, SEEK_SET, &stopOff));
     } else {
        return (ForkIoctl(fid, USDTAPE_REW, 0));
     }
@@ -654,8 +678,9 @@ incPosition(struct butm_tapeInfo *info, usd_handle_t fid, afs_uint32 dataSize)
        info->posCount = 0;
 #if (defined(AFS_SUN_ENV) || defined(AFS_LINUX24_ENV))
        if (!isafile) {
-        afs_hyper_t off;
-           hset64(off, 0, 0);
+           afs_int64 off;
+
+           off = 0;
            USD_IOCTL(fid, USD_IOCTL_SETSIZE, &off);
        }
 #endif
@@ -991,14 +1016,15 @@ file_Mount(struct butm_tapeInfo *info, char *tape)
     int xflags;
     afs_int32 code = 0, error = 0, rc = 0;
 
+    if (!info || !tape)
+       ERROR_EXIT(BUTM_BADARGUMENT);
+
     if (info->debug)
        printf("butm: Mount tape drive\n");
 
     POLL();
     info->error = 0;
 
-    if (!info || !tape)
-       ERROR_EXIT(BUTM_BADARGUMENT);
     if (info->structVersion != BUTM_MAJORVERSION)
        ERROR_EXIT(BUTM_OLDINTERFACE);
     if (info->tmRock)
@@ -1052,7 +1078,7 @@ file_Mount(struct butm_tapeInfo *info, char *tape)
 
     (void)PrepareAccess(fid);  /* for NT */
 
-    p = (struct progress *)malloc(sizeof(*p));
+    p = malloc(sizeof(*p));
     info->tmRock = (char *)p;
     p->fid = fid;
     p->mountId = config.mountId = time(0);
@@ -1126,7 +1152,7 @@ file_WriteLabel(struct butm_tapeInfo *info, struct butm_tapeLabel *label,
     afs_int32 fcode;
     struct tapeLabel *tlabel;
     struct progress *p;
-    afs_hyper_t off;           /* offset */
+    afs_int64 off;             /* offset */
 
     if (info->debug)
        printf("butm: Write tape label\n");
@@ -1149,7 +1175,7 @@ file_WriteLabel(struct butm_tapeInfo *info, struct butm_tapeLabel *label,
 
        if (isafile) {
            p = (struct progress *)info->tmRock;
-           hset64(off, 0, 0);
+           off = 0;
            code = USD_IOCTL(p->fid, USD_IOCTL_SETSIZE, &off);
            if (code)
                ERROR_EXIT(BUTM_POSITION);
@@ -1555,9 +1581,8 @@ file_Seek(struct butm_tapeInfo *info, afs_int32 position)
     afs_int32 code = 0;
     afs_int32 w;
     osi_lloff_t posit;
-    afs_uint32 c, d;
     struct progress *p;
-    afs_hyper_t startOff, stopOff;     /* for normal file(non-tape)  seeks  */
+    afs_int64 stopOff; /* for normal file(non-tape)  seeks  */
 
     if (info->debug)
        printf("butm: Seek to the tape position %d\n", position);
@@ -1572,20 +1597,10 @@ file_Seek(struct butm_tapeInfo *info, afs_int32 position)
        p = (struct progress *)info->tmRock;
        posit = (osi_lloff_t) position *(osi_lloff_t) BUTM_BLOCKSIZE;
 
-       /* Not really necessary to do it this way, should be fixed */
-#ifdef O_LARGEFILE
-       c = (posit >> 32);
-       d = (posit & 0xffffffff);
-#else
-       c = 0;
-       d = posit;
-#endif
-       hset64(startOff, c, d);
-
-       w = USD_SEEK(p->fid, startOff, SEEK_SET, &stopOff);
+       w = USD_SEEK(p->fid, posit, SEEK_SET, &stopOff);
        if (w)
            info->error = w;
-       if (hcmp(startOff, stopOff) != 0)
+       if (posit != stopOff)
            ERROR_EXIT(BUTM_POSITION);
 
        p->reading = p->writing = 0;
@@ -1616,7 +1631,7 @@ file_SeekEODump(struct butm_tapeInfo *info, afs_int32 position)
     afs_int32 blockType;
     afs_int32 w;
     struct progress *p;
-    afs_hyper_t startOff, stopOff;     /* file seek offsets */
+    afs_int64 stopOff; /* file seek offsets */
 
     if (info->debug)
        printf("butm: Seek to end-of-dump\n");
@@ -1630,16 +1645,15 @@ file_SeekEODump(struct butm_tapeInfo *info, afs_int32 position)
 
     if (isafile) {
        p = (struct progress *)info->tmRock;
-       hset64(startOff, 0, 0);
-       w = USD_SEEK(p->fid, startOff, SEEK_END, &stopOff);
+       w = USD_SEEK(p->fid, 0, SEEK_END, &stopOff);
        if (w) {
            info->error = w;
            ERROR_EXIT(BUTM_POSITION);
        }
 
-       if (hgetlo(stopOff) % BUTM_BLOCKSIZE)
+       if (stopOff % BUTM_BLOCKSIZE)
            ERROR_EXIT(BUTM_POSITION);
-       info->position = (hgetlo(stopOff) / BUTM_BLOCKSIZE);
+       info->position = (stopOff / BUTM_BLOCKSIZE);
     } else {
        /* Seek to the desired position */
        code = SeekFile(info, (position - info->position) + 1);