From: Ralph Corderoy Date: Thu, 25 May 2017 17:12:55 +0000 (+0100) Subject: Don't cast lseek(2)'s offset to off_t when it's 0. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/0bb0a48241ac6130afe4cf8eb5616f2f33ee1a84?ds=inline Don't cast lseek(2)'s offset to off_t when it's 0. `lseek(fd, (off_t)0, SEEK_SET)' does not need the cast when a prototype is in scope, and is #include'd. --- diff --git a/sbr/fdcompare.c b/sbr/fdcompare.c index 9ed1a94c..7df9a89a 100644 --- a/sbr/fdcompare.c +++ b/sbr/fdcompare.c @@ -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; } diff --git a/sbr/utils.c b/sbr/utils.c index f9bb5a97..8281b4fc 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -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)) { diff --git a/uip/annosbr.c b/uip/annosbr.c index 08201244..2c1ce75a 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -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 diff --git a/uip/distsbr.c b/uip/distsbr.c index a4c48723..c9f6656b 100644 --- a/uip/distsbr.c +++ b/uip/distsbr.c @@ -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); } diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 7c8fe246..a36d145b 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -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; } diff --git a/uip/forwsbr.c b/uip/forwsbr.c index a412d9a4..4f76c386 100644 --- a/uip/forwsbr.c +++ b/uip/forwsbr.c @@ -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 diff --git a/uip/post.c b/uip/post.c index 9723d26f..81bd7b4a 100644 --- a/uip/post.c +++ b/uip/post.c @@ -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))) diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 0c717b45..6991829e 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -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) diff --git a/uip/replsbr.c b/uip/replsbr.c index 3f40a614..e63ce755 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -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); diff --git a/uip/sendsbr.c b/uip/sendsbr.c index c0b8105c..3ada6bf0 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -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..."); diff --git a/uip/slocal.c b/uip/slocal.c index da879acf..97897ad1 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -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;