summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-07-17 15:34:41 -0700
committerKevin McCarthy <kevin@8t8.us>2021-07-17 15:34:41 -0700
commit1588a0782438226e5fac7d59ae5cb5cc126b9888 (patch)
tree775d541425f93558d2a101311891dd3cd108e10d
parentdf727efb43e751b9d089784c9c55fb6a083b25e2 (diff)
Use SEEK_SET and SEEK_END for fseek/fseeko whence parameter.
Thanks to Vincent Lefèvre for pointing out the incorrect usage. POSIX does not specify the actual values (although they are evidently commonly in use).
-rw-r--r--attach.c6
-rw-r--r--buffy.c2
-rw-r--r--copy.c8
-rw-r--r--crypt-gpgme.c10
-rw-r--r--crypt.c2
-rw-r--r--edit.c2
-rw-r--r--handler.c8
-rw-r--r--listmenu.c2
-rw-r--r--mbox.c2
-rw-r--r--pager.c2
-rw-r--r--parse.c2
-rw-r--r--pattern.c10
-rw-r--r--pgp.c8
-rw-r--r--postpone.c2
-rw-r--r--sendlib.c8
-rw-r--r--smime.c4
16 files changed, 39 insertions, 39 deletions
diff --git a/attach.c b/attach.c
index 6d658e30..486277d3 100644
--- a/attach.c
+++ b/attach.c
@@ -175,7 +175,7 @@ int mutt_compose_attachment (BODY *a)
/* Remove headers by copying out data to another file, then
* copying the file back */
- fseeko (fp, b->offset, 0);
+ fseeko (fp, b->offset, SEEK_SET);
mutt_buffer_mktemp (tempfile);
if ((tfp = safe_fopen (mutt_b2s (tempfile), "w")) == NULL)
{
@@ -781,7 +781,7 @@ int mutt_save_attachment (FILE *fp, BODY *m, const char *path, int flags, HEADER
hn->msgno = hdr->msgno; /* required for MH/maildir */
hn->read = 1;
- fseeko (fp, m->offset, 0);
+ fseeko (fp, m->offset, SEEK_SET);
if (fgets (buf, sizeof (buf), fp) == NULL)
return -1;
if (mx_open_mailbox(path, MUTT_APPEND | MUTT_QUIET, &ctx) == NULL)
@@ -817,7 +817,7 @@ int mutt_save_attachment (FILE *fp, BODY *m, const char *path, int flags, HEADER
mutt_sleep (2);
return (-1);
}
- fseeko ((s.fpin = fp), m->offset, 0);
+ fseeko ((s.fpin = fp), m->offset, SEEK_SET);
mutt_decode_attachment (m, &s);
if (fclose (s.fpout) != 0)
diff --git a/buffy.c b/buffy.c
index 2239e94f..ff11e58d 100644
--- a/buffy.c
+++ b/buffy.c
@@ -100,7 +100,7 @@ static int fseek_last_message (FILE * f)
/* here we are at the beginning of the file */
if (!mutt_strncmp ("From ", buffer, 5))
{
- fseek (f, 0, 0);
+ fseek (f, 0, SEEK_SET);
return (0);
}
diff --git a/copy.c b/copy.c
index e8f90efc..de378692 100644
--- a/copy.c
+++ b/copy.c
@@ -60,7 +60,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
int error;
if (ftello (in) != off_start)
- fseeko (in, off_start, 0);
+ fseeko (in, off_start, SEEK_SET);
buf[0] = '\n';
buf[1] = 0;
@@ -710,7 +710,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
mutt_write_mime_header (cur, fpout);
fputc ('\n', fpout);
- fseeko (fp, cur->offset, 0);
+ fseeko (fp, cur->offset, SEEK_SET);
if (mutt_copy_bytes (fp, fpout, cur->length) == -1)
{
safe_fclose (&fp);
@@ -722,7 +722,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
}
else
{
- fseeko (fpin, body->offset, 0);
+ fseeko (fpin, body->offset, SEEK_SET);
if (flags & MUTT_CM_PREFIX)
{
int c;
@@ -799,7 +799,7 @@ _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
MESSAGE *msg;
int r;
- fseeko (fpin, hdr->offset, 0);
+ fseeko (fpin, hdr->offset, SEEK_SET);
if (fgets (buf, sizeof (buf), fpin) == NULL)
return -1;
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index 74b027bd..8cbdc257 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -2157,7 +2157,7 @@ int pgp_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
}
unlink (mutt_b2s (tempfile));
- fseeko (s.fpin, b->offset, 0);
+ fseeko (s.fpin, b->offset, SEEK_SET);
s.fpout = decoded_fp;
mutt_decode_attachment (b, &s);
@@ -2236,7 +2236,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
saved_b_length = b->length;
memset (&s, 0, sizeof (s));
s.fpin = fpin;
- fseeko (s.fpin, b->offset, 0);
+ fseeko (s.fpin, b->offset, SEEK_SET);
mutt_buffer_mktemp (tempfile);
if (!(tmpfp = safe_fopen (mutt_b2s (tempfile), "w+")))
{
@@ -2290,7 +2290,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
saved_b_length = bb->length;
memset (&s, 0, sizeof (s));
s.fpin = *fpout;
- fseeko (s.fpin, bb->offset, 0);
+ fseeko (s.fpin, bb->offset, SEEK_SET);
mutt_buffer_mktemp (tempfile);
if (!(tmpfp = safe_fopen (mutt_b2s (tempfile), "w+")))
{
@@ -2775,7 +2775,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
if (!mutt_get_body_charset (body_charset, sizeof (body_charset), m))
strfcpy (body_charset, "iso-8859-1", sizeof body_charset);
- fseeko (s->fpin, m->offset, 0);
+ fseeko (s->fpin, m->offset, SEEK_SET);
last_pos = m->offset;
for (bytes = m->length; bytes > 0;)
@@ -2846,7 +2846,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
/* Copy PGP material to an data container */
armored_data = file_to_data_object (s->fpin, block_begin,
block_end - block_begin);
- fseeko (s->fpin, block_end, 0);
+ fseeko (s->fpin, block_end, SEEK_SET);
/* Invoke PGP if needed */
if (pgp_keyblock)
diff --git a/crypt.c b/crypt.c
index 4ae23340..b86e4dfe 100644
--- a/crypt.c
+++ b/crypt.c
@@ -710,7 +710,7 @@ int crypt_write_signed(BODY *a, STATE *s, const char *tempfile)
return -1;
}
- fseeko (s->fpin, a->hdr_offset, 0);
+ fseeko (s->fpin, a->hdr_offset, SEEK_SET);
bytes = a->length + a->offset - a->hdr_offset;
hadcr = 0;
while (bytes > 0)
diff --git a/edit.c b/edit.c
index 56898ec6..f46112f6 100644
--- a/edit.c
+++ b/edit.c
@@ -78,7 +78,7 @@ be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, LOFF_T offset,
tmplen = sizeof (tmp) - tmplen;
}
- fseeko (f, offset, 0);
+ fseeko (f, offset, SEEK_SET);
while (bytes > 0)
{
if (fgets (p, tmplen - 1, f) == NULL) break;
diff --git a/handler.c b/handler.c
index fbf32a37..8d27ff5e 100644
--- a/handler.c
+++ b/handler.c
@@ -1131,7 +1131,7 @@ static int alternative_handler (BODY *a, STATE *s)
{
if (s->flags & MUTT_DISPLAY && !option (OPTWEED))
{
- fseeko (s->fpin, choice->hdr_offset, 0);
+ fseeko (s->fpin, choice->hdr_offset, SEEK_SET);
mutt_copy_bytes(s->fpin, s->fpout, choice->offset-choice->hdr_offset);
}
mutt_body_handler (choice, s);
@@ -1272,7 +1272,7 @@ static int multipart_handler (BODY *a, STATE *s)
TYPE (p), p->subtype, ENCODING (p->encoding), length);
if (!option (OPTWEED))
{
- fseeko (s->fpin, p->hdr_offset, 0);
+ fseeko (s->fpin, p->hdr_offset, SEEK_SET);
mutt_copy_bytes(s->fpin, s->fpout, p->offset-p->hdr_offset);
}
else
@@ -1561,7 +1561,7 @@ void mutt_decode_attachment (BODY *b, STATE *s)
else if (istext && b->charset)
cd = mutt_iconv_open (Charset, b->charset, MUTT_ICONV_HOOK_FROM);
- fseeko (s->fpin, b->offset, 0);
+ fseeko (s->fpin, b->offset, SEEK_SET);
switch (b->encoding)
{
case ENCQUOTEDPRINTABLE:
@@ -1620,7 +1620,7 @@ static int run_decode_and_handler (BODY *b, STATE *s, handler_t handler, int pla
int decode = 0;
int rc = 0;
- fseeko (s->fpin, b->offset, 0);
+ fseeko (s->fpin, b->offset, SEEK_SET);
/* see if we need to decode this part before processing it */
if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE ||
diff --git a/listmenu.c b/listmenu.c
index d9044cec..1643f263 100644
--- a/listmenu.c
+++ b/listmenu.c
@@ -83,7 +83,7 @@ static void parse_list_headers (CONTEXT *ctx, HEADER *hdr,
if ((msg = mx_open_message (ctx, hdr->msgno, 1)) != NULL)
{
- fseeko (msg->fp, hdr->offset, 0);
+ fseeko (msg->fp, hdr->offset, SEEK_SET);
linelen = LONG_STRING;
line = safe_malloc (linelen);
diff --git a/mbox.c b/mbox.c
index 38c65c91..fc36ca22 100644
--- a/mbox.c
+++ b/mbox.c
@@ -488,7 +488,7 @@ static int mbox_open_mailbox_append (CONTEXT *ctx, int flags)
return -1;
}
- fseek (ctx->fp, 0, 2);
+ fseek (ctx->fp, 0, SEEK_END);
return 0;
}
diff --git a/pager.c b/pager.c
index bb5d495b..0444beb8 100644
--- a/pager.c
+++ b/pager.c
@@ -1179,7 +1179,7 @@ fill_buffer (FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char **buf,
if (*buf_ready == 0)
{
if (offset != *last_pos)
- fseeko (f, offset, 0);
+ fseeko (f, offset, SEEK_SET);
if ((*buf = (unsigned char *) mutt_read_line ((char *) *buf, blen, f,
NULL, MUTT_EOL)) == NULL)
diff --git a/parse.c b/parse.c
index 8cd75de5..170d104a 100644
--- a/parse.c
+++ b/parse.c
@@ -1612,7 +1612,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
continue;
}
- fseeko (f, loc, 0);
+ fseeko (f, loc, SEEK_SET);
break; /* end of header */
}
diff --git a/pattern.c b/pattern.c
index b3908d7e..a6a7f366 100644
--- a/pattern.c
+++ b/pattern.c
@@ -390,13 +390,13 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno)
goto cleanup;
}
- fseeko (msg->fp, h->offset, 0);
+ fseeko (msg->fp, h->offset, SEEK_SET);
mutt_body_handler (h->content, &s);
}
fp = s.fpout;
fflush (fp);
- fseek (fp, 0, 0);
+ fseek (fp, 0, SEEK_SET);
fstat (fileno (fp), &st);
lng = (LOFF_T) st.st_size;
}
@@ -406,13 +406,13 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno)
fp = msg->fp;
if (pat->op != MUTT_BODY)
{
- fseeko (fp, h->offset, 0);
+ fseeko (fp, h->offset, SEEK_SET);
lng = h->content->offset - h->offset;
}
if (pat->op != MUTT_HEADER)
{
if (pat->op == MUTT_BODY)
- fseeko (fp, h->content->offset, 0);
+ fseeko (fp, h->content->offset, SEEK_SET);
lng += h->content->length;
}
}
@@ -477,7 +477,7 @@ static int msg_search_sendmode (HEADER *h, pattern_t *pat)
MUTT_WRITE_HEADER_POSTPONE,
0, 0);
fflush (fp);
- fseek (fp, 0, 0);
+ fseek (fp, 0, SEEK_SET);
while ((buf = mutt_read_line (buf, &blen, fp, NULL, 0)) != NULL)
{
diff --git a/pgp.c b/pgp.c
index 8fc51c83..93093516 100644
--- a/pgp.c
+++ b/pgp.c
@@ -426,7 +426,7 @@ int pgp_application_pgp_handler (BODY *m, STATE *s)
pgperrfile = mutt_buffer_pool_get ();
tmpfname = mutt_buffer_pool_get ();
- fseeko (s->fpin, m->offset, 0);
+ fseeko (s->fpin, m->offset, SEEK_SET);
last_pos = m->offset;
for (bytes = m->length; bytes > 0;)
@@ -822,7 +822,7 @@ int pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
goto cleanup;
}
- fseeko (s->fpin, sigbdy->offset, 0);
+ fseeko (s->fpin, sigbdy->offset, SEEK_SET);
mutt_copy_bytes (s->fpin, fp, sigbdy->length);
safe_fclose (&fp);
@@ -964,7 +964,7 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
* the temporary file.
*/
- fseeko (s->fpin, a->offset, 0);
+ fseeko (s->fpin, a->offset, SEEK_SET);
mutt_copy_bytes (s->fpin, pgptmp, a->length);
safe_fclose (&pgptmp);
@@ -1101,7 +1101,7 @@ int pgp_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
}
unlink (mutt_b2s (tempfile));
- fseeko (s.fpin, b->offset, 0);
+ fseeko (s.fpin, b->offset, SEEK_SET);
s.fpout = decoded_fp;
mutt_decode_attachment (b, &s);
diff --git a/postpone.c b/postpone.c
index 2911ae15..d6e67b02 100644
--- a/postpone.c
+++ b/postpone.c
@@ -600,7 +600,7 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
/* parse the message header and MIME structure */
- fseeko (fp, hdr->offset, 0);
+ fseeko (fp, hdr->offset, SEEK_SET);
newhdr->offset = hdr->offset;
/* enable header weeding for resent messages */
newhdr->env = mutt_read_rfc822_header (fp, newhdr, 1, resend);
diff --git a/sendlib.c b/sendlib.c
index 41c1c780..8cbf011d 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -1101,7 +1101,7 @@ void mutt_message_to_7bit (BODY *a, FILE *fp)
goto cleanup;
}
- fseeko (fpin, a->offset, 0);
+ fseeko (fpin, a->offset, SEEK_SET);
a->parts = mutt_parse_messageRFC822 (fpin, a);
transform_to_7bit (a->parts, fpin);
@@ -2895,7 +2895,7 @@ static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *r
if (!option (OPTBOUNCEDELIVERED))
ch_flags |= CH_WEED_DELIVERED;
- fseeko (fp, h->offset, 0);
+ fseeko (fp, h->offset, SEEK_SET);
fprintf (f, "Resent-From: %s\n", resent_from);
date = mutt_buffer_pool_get ();
@@ -3231,10 +3231,10 @@ int mutt_write_fcc (const char *path, SEND_CONTEXT *sctx, const char *msgid, int
* this will happen, and it can cause problems parsing the mailbox
* later.
*/
- fseek (tempfp, -1, 2);
+ fseek (tempfp, -1, SEEK_END);
if (fgetc (tempfp) != '\n')
{
- fseek (tempfp, 0, 2);
+ fseek (tempfp, 0, SEEK_END);
fputc ('\n', tempfp);
}
diff --git a/smime.c b/smime.c
index 63395de9..b52b3863 100644
--- a/smime.c
+++ b/smime.c
@@ -1913,7 +1913,7 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
goto cleanup;
}
- fseeko (s->fpin, m->offset, 0);
+ fseeko (s->fpin, m->offset, SEEK_SET);
mutt_copy_bytes (s->fpin, tmpfp, m->length);
@@ -2140,7 +2140,7 @@ int smime_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
memset (&s, 0, sizeof (s));
s.fpin = fpin;
- fseeko (s.fpin, b->offset, 0);
+ fseeko (s.fpin, b->offset, SEEK_SET);
tempfile = mutt_buffer_pool_get ();
mutt_buffer_mktemp (tempfile);