static int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg)
{
- int r = fputc ('\n', msg->fp);
+ if (fputc ('\n', msg->fp) == EOF)
+ return -1;
- if (r == EOF)
+ if ((fflush (msg->fp) == EOF) ||
+ (fsync (fileno (msg->fp)) == -1))
+ {
+ mutt_perror _("Can't write message");
return -1;
+ }
return 0;
}
static int mmdf_commit_message (CONTEXT *ctx, MESSAGE *msg)
{
- int r = fputs (MMDF_SEP, msg->fp);
+ if (fputs (MMDF_SEP, msg->fp) == EOF)
+ return -1;
- if (r == EOF)
+ if ((fflush (msg->fp) == EOF) ||
+ (fsync (fileno (msg->fp)) == -1))
+ {
+ mutt_perror _("Can't write message");
return -1;
+ }
return 0;
}
int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
{
struct mx_ops *ops = mx_get_ops (ctx->magic);
- int r = 0;
if (!ops || !ops->commit_msg)
return -1;
return -1;
}
- r = ops->commit_msg (ctx, msg);
-
- if (r == 0 && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF)
- && (fflush (msg->fp) == EOF || fsync (fileno (msg->fp)) == -1))
- {
- mutt_perror _("Can't write message");
- r = -1;
- }
-
- return r;
+ return ops->commit_msg (ctx, msg);
}
/* close a pointer to a message */