]> diplodocus.org Git - nmh/commitdiff
Don't cast lseek(2)'s offset to off_t when it's 0.
authorRalph Corderoy <ralph@inputplus.co.uk>
Thu, 25 May 2017 17:12:55 +0000 (18:12 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Thu, 25 May 2017 17:12:55 +0000 (18:12 +0100)
`lseek(fd, (off_t)0, SEEK_SET)' does not need the cast when a prototype
is in scope, and <unistd.h> is #include'd.

sbr/fdcompare.c
sbr/utils.c
uip/annosbr.c
uip/distsbr.c
uip/dropsbr.c
uip/forwsbr.c
uip/post.c
uip/rcvtty.c
uip/replsbr.c
uip/sendsbr.c
uip/slocal.c

index 9ed1a94..7df9a89 100644 (file)
@@ -32,7 +32,7 @@ fdcompare (int fd1, int fd2)
     resp = 0;
 
 leave: ;
-    lseek (fd1, (off_t) 0, SEEK_SET);
-    lseek (fd2, (off_t) 0, SEEK_SET);
+    lseek(fd1, 0, SEEK_SET);
+    lseek(fd2, 0, SEEK_SET);
     return resp;
 }
index f9bb5a9..8281b4f 100644 (file)
@@ -561,7 +561,7 @@ scan_input (int fd, int *eightbit) {
     char buf[BUFSIZ];
 
     *eightbit = 0;
-    lseek (fd, (off_t) 0, SEEK_SET);
+    lseek(fd, 0, SEEK_SET);
 
     while ((state = read (fd, buf, sizeof buf)) > 0) {
         if (contains8bit (buf, buf + state)) {
index 0820124..2c1ce75 100644 (file)
@@ -402,7 +402,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, int datesw, in
        if ((tmpfd = open (tmpfil, O_RDONLY)) == NOTOK)
            adios (tmpfil, "unable to open for re-reading");
 
-       lseek (fd, (off_t) 0, SEEK_SET);
+       lseek(fd, 0, SEEK_SET);
 
        /*
         *  We're making the file shorter if we're deleting a header field
index a4c4872..c9f6656 100644 (file)
@@ -42,7 +42,7 @@ distout (char *drft, char *msgnam, char *backup)
     chmod (drft, m_gmprot ());
 
     ready_msg (msgnam);
-    lseek (hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
+    lseek(hdrfd, 0, SEEK_SET); /* msgnam not accurate */
     cpydata (hdrfd, fileno (ofp), msgnam, drft);
 
     for (resent = NULL;;) {
@@ -111,7 +111,7 @@ process: ;
     free (resent);
 
     if (txtfd != NOTOK) {
-       lseek (txtfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
+       lseek(txtfd, 0, SEEK_SET); /* msgnam not accurate */
        cpydata (txtfd, fileno (ofp), msgnam, drft);
     }
 
index 7c8fe24..a36d145 100644 (file)
@@ -82,7 +82,7 @@ mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
        if (chmod (file, mode) < 0) {
            advise (file, "chmod");
        }
-    } else if (st.st_size > (off_t) 0) {
+    } else if (st.st_size > 0) {
        int status;
 
        /* check the maildrop */
@@ -116,7 +116,7 @@ static int
 mbx_chk_mbox (int fd)
 {
     /* just seek to the end */
-    if (lseek (fd, (off_t) 0, SEEK_END) == (off_t) NOTOK)
+    if (lseek(fd, 0, SEEK_END) == (off_t) NOTOK)
        return NOTOK;
 
     return OK;
@@ -285,7 +285,7 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd,
            }
 
            fclose (fp);
-           lseek (fd, (off_t) 0, SEEK_END);
+           lseek(fd, 0, SEEK_END);
 
            return OK;
     }
index a412d9a..4f76c38 100644 (file)
@@ -189,7 +189,7 @@ finished:
     if (fclose (tmp))
        adios (tmpfil, "error writing");
 
-    lseek (in, (off_t) 0, SEEK_SET);
+    lseek(in, 0, SEEK_SET);
 
     /*
      * Free any component buffers that we allocated
index 9723d26..81bd7b4 100644 (file)
@@ -1849,7 +1849,7 @@ do_text (char *file, int fd)
     int retval, state;
     char buf[BUFSIZ];
 
-    lseek (fd, (off_t) 0, SEEK_SET);
+    lseek(fd, 0, SEEK_SET);
 
     while ((state = read (fd, buf, sizeof(buf))) > 0) {
        if (rp_isbad (retval = sm_wtxt (buf, state)))
index 0c717b4..6991829 100644 (file)
@@ -219,7 +219,7 @@ message_fd (char **vec)
            pidwait(child_id, OK);
            alarm (0);
 
-           if (fstat (fd, &st) != NOTOK && st.st_size > (off_t) 0)
+           if (fstat (fd, &st) != NOTOK && st.st_size > 0)
                return fd;
        } else {
            /*
@@ -315,7 +315,7 @@ alert (char *tty, int md)
        return;
     }
 
-    lseek (md, (off_t) 0, SEEK_SET);
+    lseek(md, 0, SEEK_SET);
 
     while ((i = read (md, buffer, sizeof(buffer))) > 0)
        if (write (td, buffer, i) != i)
index 3f40a61..e63ce75 100644 (file)
@@ -426,7 +426,7 @@ replfilter (FILE *in, FILE *out, char *filter, int fmtproc)
        adios (filter, "unable to read");
 
     rewind (in);
-    lseek (fileno(in), (off_t) 0, SEEK_SET);
+    lseek(fileno(in), 0, SEEK_SET);
 
     arglist = argsplit(mhlproc, &mhl, &argnum);
 
index c0b8105..3ada6bf 100644 (file)
@@ -537,7 +537,7 @@ alert (char *file, int out)
                if ((in = open (file, O_RDONLY)) == NOTOK) {
                    admonish (file, "unable to re-open");
                } else {
-                   lseek (out, (off_t) 0, SEEK_END);
+                   lseek(out, 0, SEEK_END);
                    strncpy (buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
                    if (write (out, buf, strlen (buf)) < 0) {
                        advise (file, "write");
@@ -556,7 +556,7 @@ alert (char *file, int out)
                        admonish (buf, "unable to rename %s to", file);
                }
            }
-           lseek (out, (off_t) 0, SEEK_SET);
+           lseek(out, 0, SEEK_SET);
            dup2 (out, fileno (stdin));
            close (out);
            /* create subject for error notification */
@@ -714,7 +714,7 @@ annoaux (int fd)
        goto oops;
     }
 
-    lseek (fd, (off_t) 0, SEEK_SET);
+    lseek(fd, 0, SEEK_SET);
     if ((fp = fdopen (fd, "r")) == NULL) {
        if (debugsw)
            inform("unable to fdopen annotation list, continuing...");
index da879ac..97897ad 100644 (file)
@@ -985,7 +985,7 @@ usr_file (int fd, char *mailbox, int mbx_style)
        return -1;
     }
 
-    lseek (fd, (off_t) 0, SEEK_SET);
+    lseek(fd, 0, SEEK_SET);
 
     /* append message to file */
     if (mbx_copy (mailbox, mbx_style, md, fd, NULL) == -1) {
@@ -1051,7 +1051,7 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress)
     if (verbose && !suppress)
        verbose_printf ("delivering to pipe \"%s\"", cmd);
 
-    lseek (fd, (off_t) 0, SEEK_SET);
+    lseek(fd, 0, SEEK_SET);
 
     for (i = 0; (child_id = fork()) == -1 && i < 5; i++)
        sleep (5);
@@ -1212,7 +1212,7 @@ you_lose:
            }
        if (i == -1)
            goto you_lose;
-       lseek (fd1, (off_t) 0, SEEK_SET);
+       lseek(fd1, 0, SEEK_SET);
        return fd1;
     }
 
@@ -1277,7 +1277,7 @@ you_lose:
        return -1;
     }
     fclose (qfp);
-    lseek (fd1, (off_t) 0, SEEK_SET);
+    lseek(fd1, 0, SEEK_SET);
     return fd1;