summaryrefslogtreecommitdiffstats
path: root/copy.c
diff options
context:
space:
mode:
authorAron Griffis <agriffis@n01se.net>2008-07-10 09:38:25 -0400
committerAron Griffis <agriffis@n01se.net>2008-07-10 09:38:25 -0400
commite9eadb389aa4bf7c69407d378254273008a8482e (patch)
treeb50a8dae3edd97f8149cf61e1c078e8af10264d6 /copy.c
parenta75736f1e5495edda4c840a16ce26ef428b92028 (diff)
Clean up error handling in mutt_copy_header
mutt_copy_header unnecessarily tests the result of each fputc/fputs (well, most of them anyway, it's not consistent). This obfuscates the code and hides bugs. Remove these extraneous checks since ferror/feof are checked at the bottom of the function, and get rid of all the early returns. Signed-off-by: Aron Griffis <agriffis@n01se.net>
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c76
1 files changed, 23 insertions, 53 deletions
diff --git a/copy.c b/copy.c
index 17c5db49..d7a96667 100644
--- a/copy.c
+++ b/copy.c
@@ -348,7 +348,7 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
| (h->env->refs_changed ? CH_UPDATE_REFS : 0);
if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
- return (-1);
+ return -1;
if (flags & CH_TXTPLAIN)
{
@@ -360,10 +360,6 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
rfc822_cat(buffer, sizeof(buffer), chsbuf, MimeSpecials);
fputs(buffer, out);
fputc('\n', out);
-
- if (ferror (out) != 0 || feof (out) != 0)
- return -1;
-
}
if (flags & CH_UPDATE)
@@ -373,24 +369,19 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
if (h->env->irt_changed && h->env->in_reply_to)
{
LIST *listp = h->env->in_reply_to;
-
- if (fputs ("In-Reply-To: ", out) == EOF)
- return (-1);
-
+ fputs ("In-Reply-To: ", out);
for (; listp; listp = listp->next)
- if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
- return (-1);
-
- if (fputc ('\n', out) == EOF)
- return (-1);
+ {
+ fputs (listp->data, out);
+ fputc (' ', out);
+ }
+ fputc ('\n', out);
}
if (h->env->refs_changed && h->env->references)
{
LIST *listp = h->env->references, *refs = NULL, *t;
-
- if (fputs ("References: ", out) == EOF)
- return (-1);
+ fputs ("References: ", out);
/* Mutt stores references in reverse order, thus we create
* a reordered refs list that we can put in the headers */
@@ -402,56 +393,36 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
}
for (; refs; refs = refs->next)
- if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
- return (-1);
+ {
+ fputs (refs->data, out);
+ fputc (' ', out);
+ }
/* clearing refs from memory */
for (t = refs; refs; refs = t->next, t = refs)
FREE (&refs);
- if (fputc ('\n', out) == EOF)
- return (-1);
+ fputc ('\n', out);
}
if (h->old || h->read)
{
- if (fputs ("Status: ", out) == EOF)
- return (-1);
-
+ fputs ("Status: ", out);
if (h->read)
- {
- if (fputs ("RO", out) == EOF)
- return (-1);
- }
+ fputs ("RO", out);
else if (h->old)
- {
- if (fputc ('O', out) == EOF)
- return (-1);
- }
-
- if (fputc ('\n', out) == EOF)
- return (-1);
+ fputc ('O', out);
+ fputc ('\n', out);
}
if (h->flagged || h->replied)
{
- if (fputs ("X-Status: ", out) == EOF)
- return (-1);
-
+ fputs ("X-Status: ", out);
if (h->replied)
- {
- if (fputc ('A', out) == EOF)
- return (-1);
- }
-
+ fputc ('A', out);
if (h->flagged)
- {
- if (fputc ('F', out) == EOF)
- return (-1);
- }
-
- if (fputc ('\n', out) == EOF)
- return (-1);
+ fputc ('F', out);
+ fputc ('\n', out);
}
}
}
@@ -468,14 +439,13 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
{
if (flags & CH_PREFIX)
fputs(prefix, out);
- if (fputc ('\n', out) == EOF) /* add header terminator */
- return (-1);
+ fputc ('\n', out); /* add header terminator */
}
if (ferror (out) || feof (out))
return -1;
- return (0);
+ return 0;
}
/* Count the number of lines and bytes to be deleted in this body*/