Split 'if' statements that combine an assignment with a test.
e.g. from:
if ((pc = imap_get_flags(&(idata->flags), pc)) == NULL)
To
pc = imap_get_flags(&(idata->flags), pc);
if (!pc)
This makes the statements a little easier to read and debug.
return;
}
- if ((new->addr = rfc822_parse_adrlist(new->addr, buf)) == NULL)
+ new->addr = rfc822_parse_adrlist(new->addr, buf);
+ if (!new->addr)
BEEP();
if (mutt_addrlist_to_intl(new->addr, &err))
{
int r;
mutt_endwin(NULL);
- if ((r = mutt_system(command)) == -1)
+ r = mutt_system(command);
+ if (r == -1)
mutt_error(_("Error running \"%s\"!"), command);
if (r != -1 && entry->composetypecommand)
FILE *fp = NULL, *tfp = NULL;
char tempfile[_POSIX_PATH_MAX];
- if ((fp = safe_fopen(a->filename, "r")) == NULL)
+ fp = safe_fopen(a->filename, "r");
+ if (!fp)
{
mutt_perror(_("Failure to open file to parse headers."));
goto bailout;
* copying the file back */
fseeko(fp, b->offset, SEEK_SET);
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((tfp = safe_fopen(tempfile, "w")) == NULL)
+ tfp = safe_fopen(tempfile, "w");
+ if (!tfp)
{
mutt_perror(_("Failure to open file to strip headers."));
goto bailout;
{
struct Body tmp = { 0 };
int n;
- if ((n = mutt_lookup_mime_type(&tmp, b->filename)) != TYPEOTHER)
+ n = mutt_lookup_mime_type(&tmp, b->filename);
+ if (n != TYPEOTHER)
{
snprintf(type, len, "%s/%s",
n == TYPEAUDIO ?
FILE *ifp = NULL, *ofp = NULL;
- if ((ifp = fopen(b->filename, "r")) == NULL)
+ ifp = fopen(b->filename, "r");
+ if (!ifp)
{
mutt_perror("fopen");
if (outfile && *outfile)
return -1;
if (mx_open_mailbox(path, MUTT_APPEND | MUTT_QUIET, &ctx) == NULL)
return -1;
- if ((msg = mx_open_new_message(&ctx, hn, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM)) == NULL)
+ msg = mx_open_new_message(&ctx, hn, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
+ if (!msg)
{
mx_close_mailbox(&ctx, NULL);
return -1;
struct State s;
memset(&s, 0, sizeof(s));
- if ((s.fpout = save_attachment_open(path, flags)) == NULL)
+ s.fpout = save_attachment_open(path, flags);
+ if (!s.fpout)
{
mutt_perror("fopen");
mutt_sleep(2);
FILE *ofp = NULL, *nfp = NULL;
- if ((ofp = fopen(m->filename, "r")) == NULL)
+ ofp = fopen(m->filename, "r");
+ if (!ofp)
{
mutt_perror("fopen");
return -1;
}
- if ((nfp = save_attachment_open(path, flags)) == NULL)
+ nfp = save_attachment_open(path, flags);
+ if (!nfp)
{
mutt_perror("fopen");
safe_fclose(&ofp);
return -1;
}
- if ((s.fpin = fopen(m->filename, "r")) == NULL)
+ s.fpin = fopen(m->filename, "r");
+ if (!s.fpin)
{
mutt_perror("fopen");
return -1;
/* interactive program */
if (piped)
{
- if ((ifp = fopen(newfile, "r")) == NULL)
+ ifp = fopen(newfile, "r");
+ if (!ifp)
{
mutt_perror("fopen");
rfc1524_free_entry(&entry);
{
mutt_debug(2, "successfully decoded %s type attachment to %s\n", type, newfile);
- if ((ifp = fopen(newfile, "r")) == NULL)
+ ifp = fopen(newfile, "r");
+ if (!ifp)
{
mutt_perror("fopen");
goto bail0;
mutt_buffy_check(false);
- if ((dp = opendir(d)) == NULL)
+ dp = opendir(d);
+ if (!dp)
{
mutt_perror(d);
return -1;
not = 1;
}
- if ((err = REGCOMP(rx, s, REG_NOSUB)) != 0)
+ err = REGCOMP(rx, s, REG_NOSUB);
+ if (err != 0)
{
regerror(err, rx, buf, sizeof(buf));
FREE(&rx);
if (!(check_new || check_stats))
return rc;
- if ((dirp = opendir(path)) == NULL)
+ dirp = opendir(path);
+ if (!dirp)
{
mailbox->magic = 0;
return 0;
fromcode2 = (fromcode2) ? fromcode2 : fromcode1;
/* call system iconv with names it appreciates */
- if ((cd = iconv_open(tocode2, fromcode2)) != (iconv_t) -1)
+ cd = iconv_open(tocode2, fromcode2);
+ if (cd != (iconv_t) -1)
return cd;
return (iconv_t) -1;
for (r = 0; r + 1 < l;)
{
- if ((c = fgetconv(_fc)) == EOF)
+ c = fgetconv(_fc);
+ if (c == EOF)
break;
buf[r++] = (char) c;
if (c == '\n')
return true;
}
- if ((cd = mutt_iconv_open(s, s, 0)) != (iconv_t)(-1))
+ cd = mutt_iconv_open(s, s, 0);
+ if (cd != (iconv_t)(-1))
{
iconv_close(cd);
return true;
mutt_extract_token(buf, s, 0);
- if ((object = mutt_getvaluebyname(buf->data, Fields)) == -1)
+ object = mutt_getvaluebyname(buf->data, Fields);
+ if (object == -1)
{
snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
return -1;
{
strfcpy(buf, NONULL(s), sizeof(buf));
mutt_check_simple(buf, sizeof(buf), NONULL(SimpleSearch));
- if ((tmp->color_pattern = mutt_pattern_comp(buf, MUTT_FULL_MSG, err)) == NULL)
+ tmp->color_pattern = mutt_pattern_comp(buf, MUTT_FULL_MSG, err);
+ if (!tmp->color_pattern)
{
free_color_line(tmp, 1);
return -1;
mutt_extract_token(buf, s, 0);
- if ((*o = mutt_getvaluebyname(buf->data, ComposeFields)) == -1)
+ *o = mutt_getvaluebyname(buf->data, ComposeFields);
+ if (*o == -1)
{
snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
return (-1);
}
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((fpout = safe_fopen(tempfile, "w")) == NULL)
+ fpout = safe_fopen(tempfile, "w");
+ if (!fpout)
{
mutt_error(_("Could not create temporary file!"));
return 0;
mutt_endwin(NULL);
snprintf(buf, sizeof(buf), "%s %s", NONULL(Pager), tempfile);
- if ((r = mutt_system(buf)) == -1)
+ r = mutt_system(buf);
+ if (r == -1)
mutt_error(_("Error running \"%s\"!"), buf);
unlink(tempfile);
if (!option(OPT_NO_CURSES))
if (decode || decrypt)
mutt_parse_mime_message(Context, h);
- if ((rc = mutt_append_message(ctx, Context, h, cmflags, chflags)) != 0)
+ rc = mutt_append_message(ctx, Context, h, cmflags, chflags);
+ if (rc != 0)
return rc;
if (delete)
int r;
snprintf(tmp, sizeof(tmp), _("Convert to %s upon sending?"),
mutt_get_parameter("charset", b->parameter));
- if ((r = mutt_yesorno(tmp, !b->noconv)) != MUTT_ABORT)
+ r = mutt_yesorno(tmp, !b->noconv);
+ if (r != MUTT_ABORT)
b->noconv = (r == MUTT_NO);
}
h->security |= PGP_TRADITIONAL_CHECKED;
mutt_parse_mime_message(Context, h);
- if ((msg = mx_open_message(Context, h->msgno)) == NULL)
+ msg = mx_open_message(Context, h->msgno);
+ if (!msg)
return 0;
if (crypt_pgp_check_traditional(msg->fp, h->content, 0))
{
* special case to handle when there is no filepart yet. find the first
* file/directory which is not ``.'' or ``..''
*/
- if ((len = mutt_strlen(filepart)) == 0)
+ len = mutt_strlen(filepart);
+ if (len == 0)
{
while ((de = readdir(dirp)) != NULL)
{
mutt_pretty_mailbox(pretty, sizeof(pretty));
snprintf(msg, sizeof(msg), _("%s [#%d] modified. Update encoding?"), pretty, i + 1);
- if ((r = mutt_yesorno(msg, MUTT_YES)) == MUTT_YES)
+ r = mutt_yesorno(msg, MUTT_YES);
+ if (r == MUTT_YES)
mutt_update_encoding(actx->idx[i]->content);
else if (r == MUTT_ABORT)
return -1;
if (!(WithCrypto & APPLICATION_PGP))
break;
new = safe_calloc(1, sizeof(struct AttachPtr));
- if ((new->content = crypt_pgp_make_key_attachment(NULL)) != NULL)
+ new->content = crypt_pgp_make_key_attachment(NULL);
+ if (new->content)
{
update_idx(menu, actx, new);
menu->redraw |= REDRAW_INDEX;
continue;
}
*p++ = 0;
- if ((itype = mutt_check_mime_type(type)) == TYPEOTHER)
+ itype = mutt_check_mime_type(type);
+ if (itype == TYPEOTHER)
{
mutt_error(_("Unknown Content-Type %s"), type);
continue;
}
safe_fclose(&fp);
- if ((new->content = mutt_make_file_attach(fname)) == NULL)
+ new->content = mutt_make_file_attach(fname);
+ if (!new->content)
{
mutt_error(_("What we have here is a failure to make an attachment"));
FREE(&new);
break;
case OP_EXIT:
- if ((i = query_quadoption(OPT_POSTPONE, _("Postpone this message?"))) == MUTT_NO)
+ i = query_quadoption(OPT_POSTPONE, _("Postpone this message?"));
+ if (i == MUTT_NO)
{
for (i = 0; i < actx->idxlen; i++)
if (actx->idx[i]->unowned)
mutt_mktemp(tmppath, sizeof(tmppath));
ctx->path = safe_strdup(tmppath);
- if ((tmpfp = safe_fopen(ctx->path, "w")) == NULL)
+ tmpfp = safe_fopen(ctx->path, "w");
+ if (!tmpfp)
return -1;
safe_fclose(&tmpfp);
struct Message *msg = NULL;
int r;
- if ((msg = mx_open_message(src, hdr->msgno)) == NULL)
+ msg = mx_open_message(src, hdr->msgno);
+ if (!msg)
return -1;
if ((r = _mutt_copy_message(fpout, msg->fp, hdr, hdr->content, flags, chflags)) == 0 &&
(ferror(fpout) || feof(fpout)))
if (fgets(buf, sizeof(buf), fpin) == NULL)
return -1;
- if ((msg = mx_open_new_message(dest, hdr, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM)) == NULL)
+ msg = mx_open_new_message(dest, hdr, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
+ if (!msg)
return -1;
if (dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF)
chflags |= CH_FROM | CH_FORCE_FROM;
struct Message *msg = NULL;
int r;
- if ((msg = mx_open_message(src, hdr->msgno)) == NULL)
+ msg = mx_open_message(src, hdr->msgno);
+ if (!msg)
return -1;
r = _mutt_append_message(dest, msg->fp, src, hdr, hdr->content, cmflags, chflags);
mx_close_message(src, &msg);
return 0;
}
- if ((a = rfc822_parse_adrlist(a, s + l)) == NULL)
+ a = rfc822_parse_adrlist(a, s + l);
+ if (!a)
return 0;
mutt_addrlist_to_local(a);
va_list ap;
int rv;
- if ((rv = mutt_window_move(win, row, col)) != ERR)
+ rv = mutt_window_move(win, row, col);
+ if (rv != ERR)
{
va_start(ap, fmt);
rv = vw_printw(stdscr, fmt, ap);
new_last_folder = safe_strdup(Context->path);
*oldcount = Context ? Context->msgcount : 0;
- if ((check = mx_close_mailbox(Context, index_hint)) != 0)
+ check = mx_close_mailbox(Context, index_hint);
+ if (check != 0)
{
if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED)
update_index(menu, Context, check, *oldcount, *index_hint);
{
/* check for new mail in the incoming folders */
oldcount = newcount;
- if ((newcount = mutt_buffy_check(false)) != oldcount)
+ newcount = mutt_buffy_check(false);
+ if (newcount != oldcount)
menu->redraw |= REDRAW_STATUS;
if (do_buffy_notify)
{
CHECK_MSGCOUNT;
CHECK_VISIBLE;
- if ((menu->current = mutt_search_command(menu->current, op)) == -1)
+ menu->current = mutt_search_command(menu->current, op);
+ if (menu->current == -1)
menu->current = menu->oldcurrent;
else
menu->redraw = REDRAW_MOTION;
newhdr = Context->hdrs[Context->v2r[newidx]];
}
- if ((check = mx_sync_mailbox(Context, &index_hint)) == 0)
+ check = mx_sync_mailbox(Context, &index_hint);
+ if (check == 0)
{
if (newhdr && Context->vcount != ovc)
for (j = 0; j < Context->vcount; j++)
}
if (option(OPT_RESOLVE))
{
- if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+ menu->current = ci_next_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
menu->redraw = REDRAW_CURRENT;
mutt_error(_("You are on the last message."));
break;
}
- if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+ menu->current = ci_next_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
if (menu->menu == MENU_MAIN)
mutt_error(_("You are on the first message."));
break;
}
- if ((menu->current = ci_previous_undeleted(menu->current)) == -1)
+ menu->current = ci_previous_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
if (menu->menu == MENU_MAIN)
menu->redraw |= REDRAW_INDEX;
else if (option(OPT_RESOLVE))
{
- if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+ menu->current = ci_next_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
menu->redraw |= REDRAW_CURRENT;
mutt_set_flag(Context, CURHDR, MUTT_FLAG, !CURHDR->flagged);
if (option(OPT_RESOLVE))
{
- if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+ menu->current = ci_next_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
menu->redraw |= REDRAW_CURRENT;
if (option(OPT_RESOLVE))
{
- if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+ menu->current = ci_next_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
menu->redraw |= REDRAW_CURRENT;
menu->redraw |= REDRAW_INDEX;
else if (option(OPT_RESOLVE))
{
- if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+ menu->current = ci_next_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
menu->redraw |= REDRAW_CURRENT;
mutt_set_flag(Context, CURHDR, MUTT_TAG, 0);
if (option(OPT_RESOLVE))
{
- if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+ menu->current = ci_next_undeleted(menu->current);
+ if (menu->current == -1)
{
menu->current = menu->oldcurrent;
menu->redraw |= REDRAW_CURRENT;
while ((fgets(buffer, sizeof(buffer), in)))
{
line++;
- if ((p = strchr(buffer, '\n')) == NULL)
+ p = strchr(buffer, '\n');
+ if (!p)
{
fprintf(stderr, "%s: Line %d too long. Ask a wizard to enlarge\n"
"%s: my buffer size.\n",
if (optind != argc)
{
- if ((f = fopen(argv[optind], "r")) == NULL)
+ f = fopen(argv[optind], "r");
+ if (!f)
{
fprintf(stderr, "%s: Can't open %s (%s).\n", Progname, argv[optind], strerror(errno));
exit(1);
{
FILE *f = NULL;
- if ((f = fopen(path, "w")) == NULL)
+ f = fopen(path, "w");
+ if (!f)
{
addstr(strerror(errno));
addch('\n');
goto bail;
}
- if ((rc = stat(tmp, &sb)) == -1)
+ rc = stat(tmp, &sb);
+ if (rc == -1)
{
mutt_error(_("Can't stat %s: %s"), tmp, strerror(errno));
goto bail;
mutt_edit_file(NONULL(Editor), tmp);
- if ((rc = stat(tmp, &sb)) == -1)
+ rc = stat(tmp, &sb);
+ if (rc == -1)
{
mutt_error(_("Can't stat %s: %s"), tmp, strerror(errno));
goto bail;
goto bail;
}
- if ((fp = fopen(tmp, "r")) == NULL)
+ fp = fopen(tmp, "r");
+ if (!fp)
{
rc = -1;
mutt_error(_("Can't open message file: %s"), strerror(errno));
goto bail;
}
- if ((rc = mutt_copy_hdr(fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL)) == 0)
+ rc = mutt_copy_hdr(fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL);
+ if (rc == 0)
{
fputc('\n', msg->fp);
mutt_copy_stream(fp, msg->fp);
mutt_block_signals_system();
- if ((thepid = fork()) == 0)
+ thepid = fork();
+ if (thepid == 0)
{
mutt_unblock_signals_system(0);
if (cur->message && cur != hdr->thread)
mutt_set_flag(Context, cur->message, flag, bf);
- if ((cur = cur->child) == NULL)
+ cur = cur->child;
+ if (!cur)
goto done;
while (true)
{
if (c == '\r' && len)
{
- if ((ch = fgetc(s->fpin)) == '\n')
+ ch = fgetc(s->fpin);
+ if (ch == '\n')
{
c = ch;
len--;
{
for (i = 0; i < 4 && len > 0; len--)
{
- if ((ch = fgetc(s->fpin)) == EOF)
+ ch = fgetc(s->fpin);
+ if (ch == EOF)
break;
if (ch >= 0 && ch < 128 && (base64val(ch) != -1 || ch == '='))
buf[i++] = ch;
while ((p = strtok(p, ",")) != NULL)
{
- if ((q = strrchr(p, '/')) != NULL)
+ q = strrchr(p, '/');
+ if (q)
{
if (*(q + 1) == '*')
{
mutt_message(_("Invoking autoview command: %s"), command);
}
- if ((fpin = safe_fopen(tempfile, "w+")) == NULL)
+ fpin = safe_fopen(tempfile, "w+");
+ if (!fpin)
{
mutt_perror("fopen");
rfc1524_free_entry(&entry);
}
#else
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((s->fpout = safe_fopen(tempfile, "w")) == NULL)
+ s->fpout = safe_fopen(tempfile, "w");
+ if (!s->fpout)
{
mutt_error(_("Unable to open temporary file!"));
mutt_debug(1, "Can't open %s.\n", tempfile);
struct stat st;
mutt_mktemp(path, sizeof(path));
- if ((ofp = safe_fopen(path, "w")) == NULL)
+ ofp = safe_fopen(path, "w");
+ if (!ofp)
{
mutt_perror(path);
return;
fputc('\n', ofp); /* tie off the header. */
/* now copy the body of the message. */
- if ((ifp = fopen(body, "r")) == NULL)
+ ifp = fopen(body, "r");
+ if (!ifp)
{
mutt_perror(body);
safe_fclose(&ofp);
mutt_list_free(&msg->env->userhdrs);
/* Read the temp file back in */
- if ((ifp = fopen(path, "r")) == NULL)
+ ifp = fopen(path, "r");
+ if (!ifp)
{
mutt_perror(path);
return;
}
- if ((ofp = safe_fopen(body, "w")) == NULL)
+ ofp = safe_fopen(body, "w");
+ if (!ofp)
{
/* intentionally leak a possible temporary file here */
safe_fclose(&ifp);
do
{
- if ((f = safe_fopen(t, "w")) == NULL)
+ f = safe_fopen(t, "w");
+ if (!f)
{
mutt_perror(t);
return;
char *linebuf = NULL, *p = NULL;
size_t buflen;
- if ((f = fopen(HistoryFile, "r")) == NULL)
+ f = fopen(HistoryFile, "r");
+ if (!f)
return;
while ((linebuf = mutt_read_line(linebuf, &buflen, f, &line, 0)) != NULL)
bool regen_file = false;
struct Hash *dup_hashes[HC_LAST] = { 0 };
- if ((f = fopen(HistoryFile, "r")) == NULL)
+ f = fopen(HistoryFile, "r");
+ if (!f)
return;
if (option(OPT_HISTORY_REMOVE_DUPS))
if (regen_file)
{
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((tmp = safe_fopen(tmpfname, "w+")) == NULL)
+ tmp = safe_fopen(tmpfname, "w+");
+ if (!tmp)
{
mutt_perror(tmpfname);
goto cleanup;
if (!s || !*s) /* This shouldn't happen, but it's safer. */
return;
- if ((f = fopen(HistoryFile, "a")) == NULL)
+ f = fopen(HistoryFile, "a");
+ if (!f)
{
mutt_perror("fopen");
return;
goto bail;
}
- if ((len = mutt_from_base64(obuf, idata->buf + 2)) == -1)
+ len = mutt_from_base64(obuf, idata->buf + 2);
+ if (len == -1)
{
mutt_debug(1, "Error decoding base64 response.\n");
goto bail;
goto err_close_conn;
if (rc == MUTT_YES)
{
- if ((rc = imap_exec(idata, "STARTTLS", IMAP_CMD_FAIL_OK)) == -1)
+ rc = imap_exec(idata, "STARTTLS", IMAP_CMD_FAIL_OK);
+ if (rc == -1)
goto bail;
if (rc != -2)
{
{
char *pc = NULL;
- if ((rc = imap_cmd_step(idata)) != IMAP_CMD_CONTINUE)
+ rc = imap_cmd_step(idata);
+ if (rc != IMAP_CMD_CONTINUE)
break;
pc = idata->buf + 2;
if (STAILQ_EMPTY(&idata->flags))
{
mutt_debug(3, "Getting mailbox FLAGS\n");
- if ((pc = imap_get_flags(&idata->flags, pc)) == NULL)
+ pc = imap_get_flags(&idata->flags, pc);
+ if (!pc)
goto fail;
}
}
mutt_list_free(&idata->flags);
/* skip "OK [PERMANENT" so syntax is the same as FLAGS */
pc += 13;
- if ((pc = imap_get_flags(&(idata->flags), pc)) == NULL)
+ pc = imap_get_flags(&(idata->flags), pc);
+ if (!pc)
goto fail;
}
/* save UIDVALIDITY for the header cache */
strfcpy(mailbox, "INBOX", sizeof(mailbox));
FREE(&mx.mbox);
- if ((rc = imap_access(ctx->path)) == 0)
+ rc = imap_access(ctx->path);
+ if (rc == 0)
return 0;
if (rc == -1)
char tmp[_POSIX_PATH_MAX];
mutt_mktemp(tmp, sizeof(tmp));
- if ((msg->fp = safe_fopen(tmp, "w")) == NULL)
+ msg->fp = safe_fopen(tmp, "w");
+ if (!msg->fp)
{
mutt_perror(tmp);
return -1;
* to be changed. */
imap_allow_reopen(ctx);
- if ((rc = imap_check(idata, 0)) != 0)
+ rc = imap_check(idata, 0);
+ if (rc != 0)
return rc;
/* if we are expunging anyway, we can do deleted messages very quickly... */
if (mutt_strncasecmp("FLAGS", s, 5) == 0)
{
- if ((s = msg_parse_flags(h, s)) == NULL)
+ s = msg_parse_flags(h, s);
+ if (!s)
return -1;
}
else if (mutt_strncasecmp("UID", s, 3) == 0)
imap_cmd_start(idata, buf);
do
{
- if ((rc = imap_cmd_step(idata)) != IMAP_CMD_CONTINUE)
+ rc = imap_cmd_step(idata);
+ if (rc != IMAP_CMD_CONTINUE)
break;
pc = idata->buf;
output_progress ? &progressbar : NULL) < 0)
goto bail;
/* pick up trailing line */
- if ((rc = imap_cmd_step(idata)) != IMAP_CMD_CONTINUE)
+ rc = imap_cmd_step(idata);
+ if (rc != IMAP_CMD_CONTINUE)
goto bail;
pc = idata->buf;
* incrementally update flags later, this won't stop us syncing */
else if ((mutt_strncasecmp("FLAGS", pc, 5) == 0) && !h->changed)
{
- if ((pc = imap_set_flags(idata, h, pc, NULL)) == NULL)
+ pc = imap_set_flags(idata, h, pc, NULL);
+ if (!pc)
goto bail;
}
}
if (!*mailbox)
strfcpy(mailbox, "INBOX", sizeof(mailbox));
- if ((fp = fopen(msg->path, "r")) == NULL)
+ fp = fopen(msg->path, "r");
+ if (!fp)
{
mutt_perror(msg->path);
goto fail;
memcpy(&old_hd, hd, sizeof(old_hd));
mutt_debug(2, "imap_set_flags: parsing FLAGS\n");
- if ((s = msg_parse_flags(&newh, s)) == NULL)
+ s = msg_parse_flags(&newh, s);
+ if (!s)
return NULL;
/* Update tags system */
}
rx = safe_malloc(sizeof(regex_t));
- if ((e = REGCOMP(rx, p, flags)) != 0)
+ e = REGCOMP(rx, p, flags);
+ if (e != 0)
{
regerror(e, rx, err->data, err->dsize);
FREE(&rx);
flags |= SORT_LAST;
}
- if ((i = mutt_getvaluebyname(s, map)) == -1)
+ i = mutt_getvaluebyname(s, map);
+ if (i == -1)
{
snprintf(err->data, err->dsize, _("%s: unknown sorting method"), s);
return -1;
break;
case GS_ADDR:
- if ((addr = mutt_parse_adrlist(NULL, buf->data)) == NULL)
+ addr = mutt_parse_adrlist(NULL, buf->data);
+ if (!addr)
goto bail;
if (mutt_addrlist_to_intl(addr, &estr))
{
rename(debugfilename, buf);
}
- if ((debugfile = safe_fopen(debugfilename, "w")) != NULL)
+ debugfile = safe_fopen(debugfilename, "w");
+ if (debugfile)
{
setbuf(debugfile, NULL); /* don't buffer the debugging output! */
mutt_debug(1, "NeoMutt/%s debugging at level %d\n", PACKAGE_VERSION, debuglevel);
mutt_debug(2, "Reading configuration file '%s'.\n", rcfile);
- if ((f = mutt_open_read(rcfile, &pid)) == NULL)
+ f = mutt_open_read(rcfile, &pid);
+ if (!f)
{
snprintf(err->data, err->dsize, "%s: %s", rcfile, strerror(errno));
return -1;
return 0;
var[vlen - 1] = '\0';
- if ((idx = mutt_option_index(var)) == -1)
+ idx = mutt_option_index(var);
+ if (idx == -1)
{
- if ((myvarval = myvar_get(var)) != NULL)
+ myvarval = myvar_get(var);
+ if (myvarval)
{
pretty_var(pt, len - (pt - buffer), var, myvarval);
return 1;
Editor = safe_strdup(p);
Visual = safe_strdup(p);
- if ((p = getenv("REPLYTO")) != NULL)
+ p = getenv("REPLYTO");
+ if (p)
{
struct Buffer buf, token;
FREE(&token.data);
}
- if ((p = getenv("EMAIL")) != NULL)
+ p = getenv("EMAIL");
+ if (p)
From = rfc822_parse_adrlist(NULL, p);
mutt_set_langinfo_charset();
c = *t;
*t = '\0';
- if ((n = mutt_getvaluebyname(s, KeyNames)) != -1)
+ n = mutt_getvaluebyname(s, KeyNames);
+ if (n != -1)
{
s = t;
*d = n;
char *key = NULL;
int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = 0, nummenus;
- if ((key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err)) == NULL)
+ key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err);
+ if (!key)
return -1;
/* function to execute */
char *seq = NULL;
char *key = NULL;
- if ((key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err)) == NULL)
+ key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err);
+ if (!key)
return -1;
mutt_extract_token(buf, s, MUTT_TOKEN_CONDENSE);
/* ad hoc support for the European MET (now officially CET) TZ */
if (mutt_strcasecmp(t, "MET") == 0)
{
- if ((t = strtok(NULL, " \t")) != NULL)
+ t = strtok(NULL, " \t");
+ if (t)
{
if (mutt_strcasecmp(t, "DST") == 0)
zhours++;
FREE(&s);
return NULL;
}
- if ((ch = strchr(s + offset, '\n')) != NULL)
+ ch = strchr(s + offset, '\n');
+ if (ch)
{
if (line)
(*line)++;
{
strfcpy(expanded_infile, infile, sizeof(expanded_infile));
mutt_expand_path(expanded_infile, sizeof(expanded_infile));
- if ((fin = fopen(expanded_infile, "r")) == NULL)
+ fin = fopen(expanded_infile, "r");
+ if (!fin)
{
if (!option(OPT_NO_CURSES))
mutt_endwin(NULL);
mutt_mktemp(buf, sizeof(buf));
tempfile = safe_strdup(buf);
- if ((fout = safe_fopen(tempfile, "w")) == NULL)
+ fout = safe_fopen(tempfile, "w");
+ if (!fout)
{
if (!option(OPT_NO_CURSES))
mutt_endwin(NULL);
fputs(bodytext, fout);
safe_fclose(&fout);
- if ((fin = fopen(tempfile, "r")) == NULL)
+ fin = fopen(tempfile, "r");
+ if (!fin)
{
if (!option(OPT_NO_CURSES))
mutt_endwin(NULL);
perror(expanded_infile);
exit(1);
}
- if ((fout = safe_fopen(expanded_infile, "a")) == NULL)
+ fout = safe_fopen(expanded_infile, "a");
+ if (!fout)
{
if (!option(OPT_NO_CURSES))
mutt_endwin(NULL);
{
int r;
- if ((r = mutt_lock_file(ctx->path, fileno(ctx->fp), excl, retry)) == 0)
+ r = mutt_lock_file(ctx->path, fileno(ctx->fp), excl, retry);
+ if (r == 0)
ctx->locked = true;
else if (retry && !excl)
{
{
int rc;
- if ((ctx->fp = fopen(ctx->path, "r")) == NULL)
+ ctx->fp = fopen(ctx->path, "r");
+ if (!ctx->fp)
{
mutt_perror(ctx->path);
return -1;
/* need to open the file for writing in such a way that it does not truncate
* the file, so use read-write mode.
*/
- if ((ctx->fp = freopen(ctx->path, "r+", ctx->fp)) == NULL)
+ ctx->fp = freopen(ctx->path, "r+", ctx->fp);
+ if (!ctx->fp)
{
mx_fastclose_mailbox(ctx);
mutt_error(_("Fatal error! Could not reopen mailbox!"));
goto bail;
}
- if ((fp = fopen(tempfile, "r")) == NULL)
+ fp = fopen(tempfile, "r");
+ if (!fp)
{
mutt_unblock_signals();
mx_fastclose_mailbox(ctx);
mbox_reset_atime(ctx, &statbuf);
/* reopen the mailbox in read-only mode */
- if ((ctx->fp = fopen(ctx->path, "r")) == NULL)
+ ctx->fp = fopen(ctx->path, "r");
+ if (!ctx->fp)
{
unlink(tempfile);
mutt_unblock_signals();
FREE(&newOffset);
FREE(&oldOffset);
- if ((ctx->fp = freopen(ctx->path, "r", ctx->fp)) == NULL)
+ ctx->fp = freopen(ctx->path, "r", ctx->fp);
+ if (!ctx->fp)
{
mutt_error(_("Could not reopen mailbox!"));
mx_fastclose_mailbox(ctx);
if (menu->search && !menu->dialog) /* Searching dialogs won't work */
{
menu->oldcurrent = menu->current;
- if ((menu->current = menu_search(menu, i)) != -1)
+ menu->current = menu_search(menu, i);
+ if (menu->current != -1)
menu->redraw = REDRAW_MOTION;
else
menu->current = menu->oldcurrent;
if (check_stats)
{
- if ((dirp = opendir(mailbox->path)) != NULL)
+ dirp = opendir(mailbox->path);
+ if (dirp)
{
while ((de = readdir(dirp)) != NULL)
{
{
snprintf(path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%" PRIu64, dest->path,
NONULL(ShortHostname), (int) getpid(), mutt_rand64());
- if ((fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
+ fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
+ if (fd == -1)
{
if (errno != EEXIST)
{
}
umask(omask);
- if ((*fp = fdopen(fd, "w")) == NULL)
+ *fp = fdopen(fd, "w");
+ if (!*fp)
{
FREE(tgt);
close(fd);
{
FILE *f = NULL;
- if ((f = fopen(fname, "r")) != NULL)
+ f = fopen(fname, "r");
+ if (f)
{
h = maildir_parse_stream(magic, f, fname, is_old, h);
safe_fclose(&f);
else
strfcpy(buf, ctx->path, sizeof(buf));
- if ((dirp = opendir(buf)) == NULL)
+ dirp = opendir(buf);
+ if (!dirp)
return -1;
while (((de = readdir(dirp)) != NULL) && (SigInt != 1))
}
snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", ctx->path);
- if ((i = creat(tmp, S_IRWXU)) == -1)
+ i = creat(tmp, S_IRWXU);
+ if (i == -1)
{
mutt_perror(tmp);
rmdir(ctx->path);
mutt_debug(2, "maildir_open_new_message (): Trying %s.\n", path);
- if ((fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
+ fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
+ if (fd == -1)
{
if (errno != EEXIST)
{
}
umask(omask);
- if ((msg->fp = fdopen(fd, "w")) == NULL)
+ msg->fp = fdopen(fd, "w");
+ if (!msg->fp)
{
FREE(&msg->path);
close(fd);
return -1;
}
- if ((dirp = opendir(ctx->path)) == NULL)
+ dirp = opendir(ctx->path);
+ if (!dirp)
{
mutt_perror(ctx->path);
return -1;
long old_body_length = h->content->length;
long old_hdr_lines = h->lines;
- if ((dest = mx_open_new_message(ctx, h, 0)) == NULL)
+ dest = mx_open_new_message(ctx, h, 0);
+ if (!dest)
return -1;
- if ((rc = mutt_copy_message(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN)) == 0)
+ rc = mutt_copy_message(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);
+ if (rc == 0)
{
snprintf(oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
strfcpy(partpath, h->path, _POSIX_PATH_MAX);
if (ctx->magic == MUTT_MH && rc == 0)
{
snprintf(newpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
- if ((rc = safe_rename(newpath, oldpath)) == 0)
+ rc = safe_rename(newpath, oldpath);
+ if (rc == 0)
mutt_str_replace(&h->path, partpath);
}
}
char suffix[16];
char *p = NULL;
- if ((p = strrchr(h->path, '/')) == NULL)
+ p = strrchr(h->path, '/');
+ if (!p)
{
mutt_debug(1, "maildir_sync_message: %s: unable to find subdir!\n", h->path);
return -1;
strfcpy(newpath, p, sizeof(newpath));
/* kill the previous flags */
- if ((p = strchr(newpath, ':')) != NULL)
+ p = strchr(newpath, ':');
+ if (p)
*p = '\0';
maildir_flags(suffix, sizeof(suffix), h);
snprintf(dir, sizeof(dir), "%s/%s", folder, subfolder);
- if ((dp = opendir(dir)) == NULL)
+ dp = opendir(dir);
+ if (!dp)
{
errno = ENOENT;
return NULL;
*/
snprintf(realpath, sizeof(realpath), "%s/%s", path,
iter == 0 ? "cur" : "new");
- if ((dp = opendir(realpath)) == NULL)
+ dp = opendir(realpath);
+ if (!dp)
return -1;
while ((de = readdir(dp)))
{
struct dirent *de = NULL;
int r = 1; /* assume empty until we find a message */
- if ((dp = opendir(path)) == NULL)
+ dp = opendir(path);
+ if (!dp)
return -1;
while ((de = readdir(dp)))
{
int rc;
mutt_allow_interrupt(1);
- if ((rc = read(conn->fd, buf, len)) == -1)
+ rc = read(conn->fd, buf, len);
+ if (rc == -1)
{
mutt_error(_("Error talking to %s (%s)"), conn->account.host, strerror(errno));
mutt_sleep(2);
int rc;
mutt_allow_interrupt(1);
- if ((rc = write(conn->fd, buf, count)) == -1)
+ rc = write(conn->fd, buf, count);
+ if (rc == -1)
{
mutt_error(_("Error talking to %s (%s)"), conn->account.host, strerror(errno));
mutt_sleep(2);
fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
if (fd >= 0)
{
- if ((rc = socket_connect(fd, cur->ai_addr)) == 0)
+ rc = socket_connect(fd, cur->ai_addr);
+ if (rc == 0)
{
fcntl(fd, F_SETFD, FD_CLOEXEC);
conn->fd = fd;
if (fd >= 0)
{
- if ((rc = socket_connect(fd, (struct sockaddr *) &sin)) == 0)
+ rc = socket_connect(fd, (struct sockaddr *) &sin);
+ if (rc == 0)
{
fcntl(fd, F_SETFD, FD_CLOEXEC);
conn->fd = fd;
SSL_CTX_set_cert_store(ctx, store);
}
- if ((fp = fopen(CertificateFile, "rt")) == NULL)
+ fp = fopen(CertificateFile, "rt");
+ if (!fp)
return 0;
while (NULL != PEM_read_X509(fp, &cert, NULL, NULL))
if (!CertificateFile)
return 0;
- if ((fp = fopen(CertificateFile, "rt")) == NULL)
+ fp = fopen(CertificateFile, "rt");
+ if (!fp)
return 0;
if (!X509_digest(peercert, EVP_sha256(), peermd, &peermdlen))
int err;
const char *errmsg = NULL;
- if ((HostExDataIndex = SSL_get_ex_new_index(0, "host", NULL, NULL, NULL)) == -1)
+ HostExDataIndex = SSL_get_ex_new_index(0, "host", NULL, NULL, NULL);
+ if (HostExDataIndex == -1)
{
mutt_debug(1, "failed to get index for application specific data\n");
return -1;
return -1;
}
- if ((SkipModeExDataIndex = SSL_get_ex_new_index(0, "skip", NULL, NULL, NULL)) == -1)
+ SkipModeExDataIndex = SSL_get_ex_new_index(0, "skip", NULL, NULL, NULL);
+ if (SkipModeExDataIndex == -1)
{
mutt_debug(1, "failed to get index for application specific data\n");
return -1;
ERR_clear_error();
- if ((err = SSL_connect(ssldata->ssl)) != 1)
+ err = SSL_connect(ssldata->ssl);
+ if (err != 1)
{
switch (SSL_get_error(ssldata->ssl, err))
{
mutt_message(_("Connecting with \"%s\"..."), Tunnel);
- if ((rc = pipe(pin)) == -1)
+ rc = pipe(pin);
+ if (rc == -1)
{
mutt_perror("pipe");
FREE(&conn->sockdata);
return -1;
}
- if ((rc = pipe(pout)) == -1)
+ rc = pipe(pout);
+ if (rc == -1)
{
mutt_perror("pipe");
close(pin[0]);
}
mutt_block_signals_system();
- if ((pid = fork()) == 0)
+ pid = fork();
+ if (pid == 0)
{
mutt_unblock_signals_system(0);
devnull = open("/dev/null", O_RDWR);
if (lstat(s, &sb) == -1 && errno == ENOENT)
return;
- if ((suffix = strrchr(prefix, '.')) != NULL)
+ suffix = strrchr(prefix, '.');
+ if (suffix)
{
*suffix = 0;
suffix++;
col -= wlen; /* reset to passed in value */
wptr = dest; /* reset write ptr */
wlen = ((flags & MUTT_FORMAT_ARROWCURSOR) && option(OPT_ARROW_CURSOR)) ? 3 : 0;
- if ((pid = mutt_create_filter(command->data, NULL, &filter, NULL)) != -1)
+ pid = mutt_create_filter(command->data, NULL, &filter, NULL);
+ if (pid != -1)
{
int rc;
if (option(OPT_CONFIRMAPPEND))
{
snprintf(tmp, sizeof(tmp), _("Append messages to %s?"), s);
- if ((rc = mutt_yesorno(tmp, MUTT_YES)) == MUTT_NO)
+ rc = mutt_yesorno(tmp, MUTT_YES);
+ if (rc == MUTT_NO)
ret = 1;
else if (rc == MUTT_ABORT)
ret = -1;
if (option(OPT_CONFIRMCREATE))
{
snprintf(tmp, sizeof(tmp), _("Create %s?"), s);
- if ((rc = mutt_yesorno(tmp, MUTT_YES)) == MUTT_NO)
+ rc = mutt_yesorno(tmp, MUTT_YES);
+ if (rc == MUTT_NO)
ret = 1;
else if (rc == MUTT_ABORT)
ret = -1;
{
mutt_expand_path(mbox, sizeof(mbox));
snprintf(buf, sizeof(buf), _("Move read messages to %s?"), mbox);
- if ((move_messages = query_quadoption(OPT_MOVE, buf)) == MUTT_ABORT)
+ move_messages = query_quadoption(OPT_MOVE, buf);
+ if (move_messages == MUTT_ABORT)
{
ctx->closing = false;
return -1;
ctx->deleted == 1 ? _("Purge %d deleted message?") :
_("Purge %d deleted messages?"),
ctx->deleted);
- if ((purge = query_quadoption(OPT_DELETE, buf)) == MUTT_ABORT)
+ purge = query_quadoption(OPT_DELETE, buf);
+ if (purge == MUTT_ABORT)
{
ctx->closing = false;
return -1;
/* allow IMAP to preserve the deleted flag across sessions */
if (ctx->magic == MUTT_IMAP)
{
- if ((check = imap_sync_mailbox(ctx, purge)) != 0)
+ check = imap_sync_mailbox(ctx, purge);
+ if (check != 0)
{
ctx->closing = false;
return check;
if (ctx->changed || ctx->deleted)
{
- if ((check = sync_mailbox(ctx, index_hint)) != 0)
+ check = sync_mailbox(ctx, index_hint);
+ if (check != 0)
{
ctx->closing = false;
return check;
ctx->deleted == 1 ? _("Purge %d deleted message?") :
_("Purge %d deleted messages?"),
ctx->deleted);
- if ((purge = query_quadoption(OPT_DELETE, buf)) == MUTT_ABORT)
+ purge = query_quadoption(OPT_DELETE, buf);
+ if (purge == MUTT_ABORT)
return -1;
else if (purge == MUTT_NO)
{
hadcr = false;
while (bytes > 0)
{
- if ((c = fgetc(s->fpin)) == EOF)
+ c = fgetc(s->fpin);
+ if (c == EOF)
break;
bytes--;
{
if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
{
- if ((*keylist = crypt_pgp_findkeys(adrlist, oppenc_mode)) == NULL)
+ *keylist = crypt_pgp_findkeys(adrlist, oppenc_mode);
+ if (!*keylist)
{
rfc822_free_address(&adrlist);
return -1;
}
if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME))
{
- if ((*keylist = crypt_smime_findkeys(adrlist, oppenc_mode)) == NULL)
+ *keylist = crypt_smime_findkeys(adrlist, oppenc_mode);
+ if (!*keylist)
{
rfc822_free_address(&adrlist);
return -1;
mutt_mktemp(tempfb, sizeof(tempfb));
tempf = tempfb;
}
- if ((fp = safe_fopen(tempf, tempf == tempfb ? "w+" : "a+")) == NULL)
+ fp = safe_fopen(tempf, tempf == tempfb ? "w+" : "a+");
+ if (!fp)
{
mutt_perror(_("Can't create temporary file"));
return NULL;
saved_length = b->length;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((decoded_fp = safe_fopen(tempfile, "w+")) == NULL)
+ decoded_fp = safe_fopen(tempfile, "w+");
+ if (!decoded_fp)
{
mutt_perror(tempfile);
return -1;
}
unlink(tempfile);
- if ((*cur = decrypt_part(b, &s, *fpout, 0, &is_signed)) == NULL)
+ *cur = decrypt_part(b, &s, *fpout, 0, &is_signed);
+ if (!*cur)
rv = -1;
rewind(*fpout);
if (is_signed > 0)
int rc = -1;
time_t tt;
- if ((err = gpgme_new(&tmpctx)) != GPG_ERR_NO_ERROR)
+ err = gpgme_new(&tmpctx);
+ if (err != GPG_ERR_NO_ERROR)
{
mutt_debug(1, "Error creating GPGME context\n");
return rc;
}
}
- if ((err = gpgme_op_import(tmpctx, keydata)) != GPG_ERR_NO_ERROR)
+ err = gpgme_op_import(tmpctx, keydata);
+ if (err != GPG_ERR_NO_ERROR)
{
mutt_debug(1, "Error importing key\n");
goto err_tmpdir;
return 0;
}
- if ((tfp = fopen(tempfile, "r")) == NULL)
+ tfp = fopen(tempfile, "r");
+ if (!tfp)
{
unlink(tempfile);
return 0;
/* Note that the stream, "in", needs to be kept open while the keydata
* is used.
*/
- if ((err = gpgme_data_new_from_stream(&keydata, in)) != GPG_ERR_NO_ERROR)
+ err = gpgme_data_new_from_stream(&keydata, in);
+ if (err != GPG_ERR_NO_ERROR)
{
safe_fclose(&in);
mutt_error(_("error allocating data object: %s\n"), gpgme_strerror(err));
char *scratch = NULL;
char *t = NULL;
- if ((scratch = safe_strdup(str)) == NULL)
+ scratch = safe_strdup(str);
+ if (!scratch)
return;
for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
int is_sub;
int devnull;
- if ((devnull = open("/dev/null", O_RDWR)) == -1)
+ devnull = open("/dev/null", O_RDWR);
+ if (devnull == -1)
return NULL;
mutt_str_replace(&_chs, Charset);
/* Copy PGP material to temporary file */
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((tmpfp = safe_fopen(tmpfname, "w+")) == NULL)
+ tmpfp = safe_fopen(tmpfname, "w+");
+ if (!tmpfp)
{
mutt_perror(tmpfname);
FREE(&gpgcharset);
if (!clearsign || (s->flags & MUTT_VERIFY))
{
mutt_mktemp(outfile, sizeof(outfile));
- if ((pgpout = safe_fopen(outfile, "w+")) == NULL)
+ pgpout = safe_fopen(outfile, "w+");
+ if (!pgpout)
{
mutt_perror(outfile);
safe_fclose(&tmpfp);
return 0;
}
- if ((tfp = fopen(tempfile, "r")) == NULL)
+ tfp = fopen(tempfile, "r");
+ if (!tfp)
{
unlink(tempfile);
return 0;
int rv;
mutt_mktemp(pgperrfile, sizeof(pgperrfile));
- if ((pgperr = safe_fopen(pgperrfile, "w+")) == NULL)
+ pgperr = safe_fopen(pgperrfile, "w+");
+ if (!pgperr)
{
mutt_perror(pgperrfile);
return NULL;
unlink(pgperrfile);
mutt_mktemp(pgptmpfile, sizeof(pgptmpfile));
- if ((pgptmp = safe_fopen(pgptmpfile, "w")) == NULL)
+ pgptmp = safe_fopen(pgptmpfile, "w");
+ if (!pgptmp)
{
mutt_perror(pgptmpfile);
safe_fclose(&pgperr);
rewind(fpout);
- if ((tattach = mutt_read_mime_header(fpout, 0)) != NULL)
+ tattach = mutt_read_mime_header(fpout, 0);
+ if (tattach)
{
/*
* Need to set the length of this body part.
saved_length = b->length;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((decoded_fp = safe_fopen(tempfile, "w+")) == NULL)
+ decoded_fp = safe_fopen(tempfile, "w+");
+ if (!decoded_fp)
{
mutt_perror(tempfile);
return -1;
}
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((*fpout = safe_fopen(tempfile, "w+")) == NULL)
+ *fpout = safe_fopen(tempfile, "w+");
+ if (!*fpout)
{
mutt_perror(tempfile);
rv = -1;
}
unlink(tempfile);
- if ((*cur = pgp_decrypt_part(b, &s, *fpout, p)) == NULL)
+ *cur = pgp_decrypt_part(b, &s, *fpout, p);
+ if (!*cur)
rv = -1;
rewind(*fpout);
int rc = 0;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((fpout = safe_fopen(tempfile, "w+")) == NULL)
+ fpout = safe_fopen(tempfile, "w+");
+ if (!fpout)
{
if (s->flags & MUTT_DISPLAY)
state_attach_puts(_("[-- Error: could not create temporary file! --]\n"), s);
if (s->flags & MUTT_DISPLAY)
crypt_current_time(s, "PGP");
- if ((tattach = pgp_decrypt_part(a, s, fpout, a)) != NULL)
+ tattach = pgp_decrypt_part(a, s, fpout, a);
+ if (tattach)
{
if (s->flags & MUTT_DISPLAY)
state_attach_puts(
convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
mutt_mktemp(sigfile, sizeof(sigfile));
- if ((fp = safe_fopen(sigfile, "w")) == NULL)
+ fp = safe_fopen(sigfile, "w");
+ if (!fp)
{
return NULL;
}
mutt_mktemp(signedfile, sizeof(signedfile));
- if ((sfp = safe_fopen(signedfile, "w")) == NULL)
+ sfp = safe_fopen(signedfile, "w");
+ if (!sfp)
{
mutt_perror(signedfile);
safe_fclose(&fp);
mutt_write_mime_body(a, sfp);
safe_fclose(&sfp);
- if ((thepid = pgp_invoke_sign(&pgpin, &pgpout, &pgperr, -1, -1, -1, signedfile)) == -1)
+ thepid = pgp_invoke_sign(&pgpin, &pgpout, &pgperr, -1, -1, -1, signedfile);
+ if (thepid == -1)
{
mutt_perror(_("Can't open PGP subprocess!"));
safe_fclose(&fp);
pid_t thepid;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((fpout = safe_fopen(tempfile, "w+")) == NULL)
+ fpout = safe_fopen(tempfile, "w+");
+ if (!fpout)
{
mutt_perror(tempfile);
return NULL;
}
mutt_mktemp(pgperrfile, sizeof(pgperrfile));
- if ((pgperr = safe_fopen(pgperrfile, "w+")) == NULL)
+ pgperr = safe_fopen(pgperrfile, "w+");
+ if (!pgperr)
{
mutt_perror(pgperrfile);
unlink(tempfile);
unlink(pgperrfile);
mutt_mktemp(pgpinfile, sizeof(pgpinfile));
- if ((fptmp = safe_fopen(pgpinfile, "w")) == NULL)
+ fptmp = safe_fopen(pgpinfile, "w");
+ if (!fptmp)
{
mutt_perror(pgpinfile);
unlink(tempfile);
if (mutt_strcasecmp(a->subtype, "plain") != 0)
return NULL;
- if ((fp = fopen(a->filename, "r")) == NULL)
+ fp = fopen(a->filename, "r");
+ if (!fp)
{
mutt_perror(a->filename);
return NULL;
}
mutt_mktemp(pgpinfile, sizeof(pgpinfile));
- if ((pgpin = safe_fopen(pgpinfile, "w")) == NULL)
+ pgpin = safe_fopen(pgpinfile, "w");
+ if (!pgpin)
{
mutt_perror(pgpinfile);
safe_fclose(&fp);
case OP_VERIFY_KEY:
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((devnull = fopen("/dev/null", "w")) == NULL)
+ devnull = fopen("/dev/null", "w");
+ if (!devnull)
{
mutt_perror(_("Can't open /dev/null"));
break;
}
- if ((fp = safe_fopen(tempfile, "w")) == NULL)
+ fp = safe_fopen(tempfile, "w");
+ if (!fp)
{
safe_fclose(&devnull);
mutt_perror(_("Can't create temporary file"));
tempf = tempfb;
}
- if ((tempfp = safe_fopen(tempf, tempf == tempfb ? "w" : "a")) == NULL)
+ tempfp = safe_fopen(tempf, tempf == tempfb ? "w" : "a");
+ if (!tempfp)
{
mutt_perror(_("Can't create temporary file"));
return NULL;
}
- if ((devnull = fopen("/dev/null", "w")) == NULL)
+ devnull = fopen("/dev/null", "w");
+ if (!devnull)
{
mutt_perror(_("Can't open /dev/null"));
safe_fclose(&tempfp);
char *scratch = NULL;
char *t = NULL;
- if ((scratch = safe_strdup(str)) == NULL)
+ scratch = safe_strdup(str);
+ if (!scratch)
return;
for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
short rv = -1;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((out = safe_fopen(tempfile, "w+")) == NULL)
+ out = safe_fopen(tempfile, "w+");
+ if (!out)
{
mutt_perror(tempfile);
goto bye;
}
unlink(tempfile);
- if ((in = fopen(fname, "r")) == NULL)
+ in = fopen(fname, "r");
+ if (!in)
{
mutt_perror(fname);
goto bye;
pgp_dearmor(in, out);
rewind(out);
- if ((p = pgp_read_packet(out, &l)) != NULL)
+ p = pgp_read_packet(out, &l);
+ if (p)
{
rv = pgp_mic_from_packet(p, l);
}
snprintf(index_file, sizeof(index_file), "%s/.index",
public ? NONULL(SmimeCertificates) : NONULL(SmimeKeys));
- if ((fp = safe_fopen(index_file, "r")) == NULL)
+ fp = safe_fopen(index_file, "r");
+ if (!fp)
{
mutt_perror(index_file);
return NULL;
size_t len = 0;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+ fperr = safe_fopen(tmpfname, "w+");
+ if (!fperr)
{
mutt_perror(tmpfname);
return 1;
mutt_unlink(tmpfname);
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((fpout = safe_fopen(tmpfname, "w+")) == NULL)
+ fpout = safe_fopen(tmpfname, "w+");
+ if (!fpout)
{
safe_fclose(&fperr);
mutt_perror(tmpfname);
int empty;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+ fperr = safe_fopen(tmpfname, "w+");
+ if (!fperr)
{
mutt_perror(tmpfname);
return NULL;
mutt_unlink(tmpfname);
mutt_mktemp(pk7out, sizeof(pk7out));
- if ((fpout = safe_fopen(pk7out, "w+")) == NULL)
+ fpout = safe_fopen(pk7out, "w+");
+ if (!fpout)
{
safe_fclose(&fperr);
mutt_perror(pk7out);
safe_fclose(&fpout);
mutt_mktemp(certfile, sizeof(certfile));
- if ((fpout = safe_fopen(certfile, "w+")) == NULL)
+ fpout = safe_fopen(certfile, "w+");
+ if (!fpout)
{
safe_fclose(&fperr);
mutt_unlink(pk7out);
int empty;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+ fperr = safe_fopen(tmpfname, "w+");
+ if (!fperr)
{
mutt_perror(tmpfname);
return NULL;
mutt_unlink(tmpfname);
mutt_mktemp(certfile, sizeof(certfile));
- if ((fpout = safe_fopen(certfile, "w+")) == NULL)
+ fpout = safe_fopen(certfile, "w+");
+ if (!fpout)
{
safe_fclose(&fperr);
mutt_perror(certfile);
pid_t thepid = -1;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+ fperr = safe_fopen(tmpfname, "w+");
+ if (!fperr)
{
mutt_perror(tmpfname);
return;
mutt_unlink(tmpfname);
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((fpout = safe_fopen(tmpfname, "w+")) == NULL)
+ fpout = safe_fopen(tmpfname, "w+");
+ if (!fpout)
{
safe_fclose(&fperr);
mutt_perror(tmpfname);
pid_t thepid;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((fpout = safe_fopen(tempfile, "w+")) == NULL)
+ fpout = safe_fopen(tempfile, "w+");
+ if (!fpout)
{
mutt_perror(tempfile);
return NULL;
}
mutt_mktemp(smimeerrfile, sizeof(smimeerrfile));
- if ((smimeerr = safe_fopen(smimeerrfile, "w+")) == NULL)
+ smimeerr = safe_fopen(smimeerrfile, "w+");
+ if (!smimeerr)
{
mutt_perror(smimeerrfile);
safe_fclose(&fpout);
mutt_unlink(smimeerrfile);
mutt_mktemp(smimeinfile, sizeof(smimeinfile));
- if ((fptmp = safe_fopen(smimeinfile, "w+")) == NULL)
+ fptmp = safe_fopen(smimeinfile, "w+");
+ if (!fptmp)
{
mutt_perror(smimeinfile);
mutt_unlink(tempfile);
convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
mutt_mktemp(filetosign, sizeof(filetosign));
- if ((sfp = safe_fopen(filetosign, "w+")) == NULL)
+ sfp = safe_fopen(filetosign, "w+");
+ if (!sfp)
{
mutt_perror(filetosign);
return NULL;
}
mutt_mktemp(signedfile, sizeof(signedfile));
- if ((smimeout = safe_fopen(signedfile, "w+")) == NULL)
+ smimeout = safe_fopen(signedfile, "w+");
+ if (!smimeout)
{
mutt_perror(signedfile);
safe_fclose(&sfp);
/* decode to a tempfile, saving the original destination */
fp = s->fpout;
- if ((s->fpout = safe_fopen(signedfile, "w")) == NULL)
+ s->fpout = safe_fopen(signedfile, "w");
+ if (!s->fpout)
{
mutt_perror(signedfile);
return -1;
return NULL;
mutt_mktemp(outfile, sizeof(outfile));
- if ((smimeout = safe_fopen(outfile, "w+")) == NULL)
+ smimeout = safe_fopen(outfile, "w+");
+ if (!smimeout)
{
mutt_perror(outfile);
return NULL;
}
mutt_mktemp(errfile, sizeof(errfile));
- if ((smimeerr = safe_fopen(errfile, "w+")) == NULL)
+ smimeerr = safe_fopen(errfile, "w+");
+ if (!smimeerr)
{
mutt_perror(errfile);
safe_fclose(&smimeout);
mutt_unlink(errfile);
mutt_mktemp(tmpfname, sizeof(tmpfname));
- if ((tmpfp = safe_fopen(tmpfname, "w+")) == NULL)
+ tmpfp = safe_fopen(tmpfname, "w+");
+ if (!tmpfp)
{
mutt_perror(tmpfname);
safe_fclose(&smimeout);
fflush(smimeerr);
rewind(smimeerr);
- if ((c = fgetc(smimeerr)) != EOF)
+ c = fgetc(smimeerr);
+ if (c != EOF)
{
ungetc(c, smimeerr);
else
{
mutt_mktemp(tmptmpfname, sizeof(tmptmpfname));
- if ((fpout = safe_fopen(tmptmpfname, "w+")) == NULL)
+ fpout = safe_fopen(tmptmpfname, "w+");
+ if (!fpout)
{
mutt_perror(tmptmpfname);
safe_fclose(&smimeout);
fflush(fpout);
rewind(fpout);
- if ((p = mutt_read_mime_header(fpout, 0)) != NULL)
+ p = mutt_read_mime_header(fpout, 0);
+ if (p)
{
fstat(fileno(fpout), &info);
p->length = info.st_size - p->offset;
fseeko(s.fpin, b->offset, SEEK_SET);
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((tmpfp = safe_fopen(tempfile, "w+")) == NULL)
+ tmpfp = safe_fopen(tempfile, "w+");
+ if (!tmpfp)
{
mutt_perror(tempfile);
return -1;
s.fpout = 0;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((*fpout = safe_fopen(tempfile, "w+")) == NULL)
+ *fpout = safe_fopen(tempfile, "w+");
+ if (!*fpout)
{
mutt_perror(tempfile);
rv = -1;
{
if (offset != *last_pos)
fseeko(f, offset, SEEK_SET);
- if ((*buf = (unsigned char *) mutt_read_line((char *) *buf, blen, f, &l, MUTT_EOL)) == NULL)
+ *buf = (unsigned char *) mutt_read_line((char *) *buf, blen, f, &l, MUTT_EOL);
+ if (!*buf)
{
fmt[0] = 0;
return -1;
rd.searchbuf = searchbuf;
rd.has_types = (IsHeader(extra) || (flags & MUTT_SHOWCOLOR)) ? MUTT_TYPES : 0; /* main message or rfc822 attachment */
- if ((rd.fp = fopen(fname, "r")) == NULL)
+ rd.fp = fopen(fname, "r");
+ if (!rd.fp)
{
mutt_perror(fname);
return -1;
while (*s)
{
- if ((p = strpbrk(s, "=;")) == NULL)
+ p = strpbrk(s, "=;");
+ if (!p)
{
mutt_debug(1, "parse_parameters: malformed parameter: %s\n", s);
goto bail;
mutt_free_parameter(&ct->parameter);
/* First extract any existing parameters */
- if ((pc = strchr(s, ';')) != NULL)
+ pc = strchr(s, ';');
+ if (pc)
{
*pc++ = 0;
while (*pc && ISSPACE(*pc))
ct->disposition = DISPATTACH;
/* Check to see if a default filename was given */
- if ((s = strchr(s, ';')) != NULL)
+ s = strchr(s, ';');
+ if (s)
{
s = skip_email_wsp(s + 1);
if ((s = mutt_get_parameter("filename", (parms = parse_parameters(s)))))
const char *q = NULL;
/* check for a simple whitespace separated list of addresses */
- if ((q = strpbrk(s, "\"<>():;,\\")) == NULL)
+ q = strpbrk(s, "\"<>():;,\\");
+ if (!q)
{
char tmp[HUGE_STRING];
char *r = NULL;
if (isdigit((unsigned char) *pc))
{
/* minimum date specified */
- if ((pc = get_date(pc, &min, err)) == NULL)
+ pc = get_date(pc, &min, err);
+ if (!pc)
{
FREE(&buffer.data);
return false;
struct stat st;
#endif
- if ((msg = mx_open_message(ctx, msgno)) != NULL)
+ msg = mx_open_message(ctx, msgno);
+ if (msg)
{
if (option(OPT_THOROUGH_SEARCH))
{
}
#else
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((s.fpout = safe_fopen(tempfile, "w+")) == NULL)
+ s.fpout = safe_fopen(tempfile, "w+");
+ if (!s.fpout)
{
mutt_perror(tempfile);
return 0;
isalias = false;
/* compile the sub-expression */
buf = mutt_substrdup(ps.dptr + 1, p);
- if ((tmp2 = mutt_pattern_comp(buf, flags, err)) == NULL)
+ tmp2 = mutt_pattern_comp(buf, flags, err);
+ if (!tmp2)
{
FREE(&buf);
mutt_pattern_free(&curlist);
last = tmp;
ps.dptr++; /* move past the ~ */
- if ((entry = lookup_tag(*ps.dptr)) == NULL)
+ entry = lookup_tag(*ps.dptr);
+ if (!entry)
{
snprintf(err->data, err->dsize, _("%c: invalid pattern modifier"), *ps.dptr);
mutt_pattern_free(&curlist);
}
/* compile the sub-expression */
buf = mutt_substrdup(ps.dptr + 1, p);
- if ((tmp = mutt_pattern_comp(buf, flags, err)) == NULL)
+ tmp = mutt_pattern_comp(buf, flags, err);
+ if (!tmp)
{
FREE(&buf);
mutt_pattern_free(&curlist);
mutt_buffer_init(&err);
err.dsize = STRING;
err.data = safe_malloc(err.dsize);
- if ((pat = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err)) == NULL)
+ pat = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err);
+ if (!pat)
{
FREE(&simple);
mutt_error("%s", err.data);
mutt_pattern_free(&SearchPattern);
err.dsize = STRING;
err.data = safe_malloc(err.dsize);
- if ((SearchPattern = mutt_pattern_comp(temp, MUTT_FULL_MSG, &err)) == NULL)
+ SearchPattern = mutt_pattern_comp(temp, MUTT_FULL_MSG, &err);
+ if (!SearchPattern)
{
mutt_error("%s", err.data);
FREE(&err.data);
short err = 0;
- if ((rfp = fopen(ringfile, "r")) == NULL)
+ rfp = fopen(ringfile, "r");
+ if (!rfp)
{
char *error_buf = NULL;
size_t error_buf_len;
/* Not bailing out here would lead us into an endless loop. */
- if ((p = pgp_parse_keyblock(rfp)) == NULL)
+ p = pgp_parse_keyblock(rfp);
+ if (!p)
err = 1;
pgpring_dump_keyblock(p);
if (!ctx->quiet)
mutt_progress_update(&progress, j, -1);
snprintf(buf, sizeof(buf), "DELE %d\r\n", ctx->hdrs[i]->refno);
- if ((ret = pop_query(pop_data, buf, sizeof(buf))) == 0)
+ ret = pop_query(pop_data, buf, sizeof(buf));
+ if (ret == 0)
{
mutt_bcache_del(pop_data->bcache, ctx->hdrs[i]->data);
#ifdef USE_HCACHE
for (int i = last + 1; i <= msgs; i++)
{
- if ((msg = mx_open_new_message(&ctx, NULL, MUTT_ADD_FROM)) == NULL)
+ msg = mx_open_new_message(&ctx, NULL, MUTT_ADD_FROM);
+ if (!msg)
ret = -3;
else
{
if (!Postponed)
return -1;
- if ((PostContext = mx_open_mailbox(Postponed, MUTT_NOSORT, NULL)) == NULL)
+ PostContext = mx_open_mailbox(Postponed, MUTT_NOSORT, NULL);
+ if (!PostContext)
{
PostCount = 0;
mutt_error(_("No postponed messages."));
}
mutt_adv_mktemp(file, sizeof(file));
- if ((s.fpout = safe_fopen(file, "w")) == NULL)
+ s.fpout = safe_fopen(file, "w");
+ if (!s.fpout)
goto bail;
if ((WithCrypto & APPLICATION_PGP) &&
struct stat st;
/* check to make sure that this file is really the one the user wants */
- if ((rc = mutt_save_confirm(buf, &st)) == 1)
+ rc = mutt_save_confirm(buf, &st);
+ if (rc == 1)
{
prompt = _("Save to file: ");
continue;
}
else
{
- if ((ifp = fopen(b->filename, "r")) == NULL)
+ ifp = fopen(b->filename, "r");
+ if (!ifp)
{
mutt_perror("fopen");
return;
mutt_mktemp(newfile, sizeof(newfile));
if (mutt_decode_save_attachment(fp, top, newfile, MUTT_PRINTING, 0) == 0)
{
- if ((ifp = fopen(newfile, "r")) != NULL)
+ ifp = fopen(newfile, "r");
+ if (ifp)
{
mutt_copy_stream(ifp, state->fpout);
safe_fclose(&ifp);
mutt_message_hook(Context, hdr, MUTT_MESSAGEHOOK);
- if ((msg = mx_open_message(Context, hdr->msgno)) == NULL)
+ msg = mx_open_message(Context, hdr->msgno);
+ if (!msg)
return;
menu = mutt_new_menu(MENU_ATTACH);
mutt_make_forward_subject(tmphdr->env, Context, parent_hdr);
mutt_mktemp(tmpbody, sizeof(tmpbody));
- if ((tmpfp = safe_fopen(tmpbody, "w")) == NULL)
+ tmpfp = safe_fopen(tmpbody, "w");
+ if (!tmpfp)
{
mutt_error(_("Can't open temporary file %s."), tmpbody);
mutt_free_header(&tmphdr);
if (!check_all_msg(actx, cur, false))
{
nattach = count_tagged(actx);
- if ((parent = find_parent(actx, cur, nattach)) != NULL)
+ parent = find_parent(actx, cur, nattach);
+ if (parent)
{
parent_hdr = parent->content->hdr;
parent_fp = parent->fp;
}
mutt_mktemp(tmpbody, sizeof(tmpbody));
- if ((tmpfp = safe_fopen(tmpbody, "w")) == NULL)
+ tmpfp = safe_fopen(tmpbody, "w");
+ if (!tmpfp)
{
mutt_error(_("Can't create %s."), tmpbody);
mutt_free_header(&tmphdr);
if (!l)
return NULL;
- if ((devnull = open("/dev/null", O_RDWR)) == -1)
+ devnull = open("/dev/null", O_RDWR);
+ if (devnull == -1)
return NULL;
snprintf(cmd, sizeof(cmd), "%s -T", Mixmaster);
- if ((mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, devnull, -1, devnull)) == -1)
+ mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, devnull, -1, devnull);
+ if (mm_pid == -1)
{
close(devnull);
return NULL;
SLtt_Screen_Rows = -1;
SLtt_Screen_Cols = -1;
- if ((fd = open("/dev/tty", O_RDONLY)) != -1)
+ fd = open("/dev/tty", O_RDONLY);
+ if (fd != -1)
{
if (ioctl(fd, TIOCGWINSZ, &w) != -1)
{
*/
/* find length of basetype */
- if ((ch = strchr(type, '/')) == NULL)
+ ch = strchr(type, '/');
+ if (!ch)
return false;
btlen = ch - type;
- if ((fp = fopen(filename, "r")) != NULL)
+ fp = fopen(filename, "r");
+ if (fp)
{
while (!found && (buf = mutt_read_line(buf, &buflen, fp, &line, MUTT_CONT)) != NULL)
{
return 1;
if (access(newfile, F_OK) == 0)
return 2;
- if ((ofp = fopen(oldfile, "r")) == NULL)
+ ofp = fopen(oldfile, "r");
+ if (!ofp)
return 3;
- if ((nfp = safe_fopen(newfile, "w")) == NULL)
+ nfp = safe_fopen(newfile, "w");
+ if (!nfp)
{
safe_fclose(&ofp);
return 3;
s += m;
}
- if ((m = n - lwsrlen(s, n)) != 0)
+ m = n - lwsrlen(s, n);
+ if (m != 0)
{
if (m > dlen)
m = dlen;
mutt_debug(2, "f=f: postprocess %s\n", hdr->content->filename);
- if ((in = safe_fopen(hdr->content->filename, "r")) == NULL)
+ in = safe_fopen(hdr->content->filename, "r");
+ if (!in)
return;
mutt_mktemp(tmpfile, sizeof(tmpfile));
- if ((out = safe_fopen(tmpfile, "w+")) == NULL)
+ out = safe_fopen(tmpfile, "w+");
+ if (!out)
{
safe_fclose(&in);
return;
{
if (commentlen && commentlen < sizeof(comment) - 1)
comment[commentlen++] = ' ';
- if ((ps = next_token(s, comment, &commentlen, sizeof(comment) - 1)) == NULL)
+ ps = next_token(s, comment, &commentlen, sizeof(comment) - 1);
+ if (!ps)
{
rfc822_free_address(&top);
return NULL;
{
if (phraselen && phraselen < sizeof(phrase) - 1)
phrase[phraselen++] = ' ';
- if ((ps = parse_quote(s + 1, phrase, &phraselen, sizeof(phrase) - 1)) == NULL)
+ ps = parse_quote(s + 1, phrase, &phraselen, sizeof(phrase) - 1);
+ if (!ps)
{
rfc822_free_address(&top);
return NULL;
cur = rfc822_new_address();
if (phraselen)
cur->personal = safe_strdup(phrase);
- if ((ps = parse_route_addr(s + 1, comment, &commentlen, sizeof(comment) - 1, cur)) == NULL)
+ ps = parse_route_addr(s + 1, comment, &commentlen, sizeof(comment) - 1, cur);
+ if (!ps)
{
rfc822_free_address(&top);
rfc822_free_address(&cur);
{
if (phraselen && phraselen < sizeof(phrase) - 1 && ws_pending)
phrase[phraselen++] = ' ';
- if ((ps = next_token(s, phrase, &phraselen, sizeof(phrase) - 1)) == NULL)
+ ps = next_token(s, phrase, &phraselen, sizeof(phrase) - 1);
+ if (!ps)
{
rfc822_free_address(&top);
return NULL;
break;
if (!ptr)
{
- if ((pat = mutt_pattern_comp(pattern, 0, err)) == NULL)
+ pat = mutt_pattern_comp(pattern, 0, err);
+ if (!pat)
{
FREE(&pattern);
return -1;
return -1;
rfc822_free_address(a);
*a = mutt_expand_aliases(mutt_parse_adrlist(NULL, buf));
- if ((idna_ok = mutt_addrlist_to_intl(*a, &err)) != 0)
+ idna_ok = mutt_addrlist_to_intl(*a, &err);
+ if (idna_ok != 0)
{
mutt_error(_("Error: '%s' is a bad IDN."), err);
mutt_refresh();
in->mail_followup_to->mailbox,
in->mail_followup_to->next ? ",..." : "");
- if ((hmfupto = query_quadoption(OPT_HONOR_FOLLOWUP_TO, prompt)) == MUTT_ABORT)
+ hmfupto = query_quadoption(OPT_HONOR_FOLLOWUP_TO, prompt);
+ if (hmfupto == MUTT_ABORT)
return -1;
}
if (flags & SENDREPLY)
{
- if ((i = query_quadoption(OPT_INCLUDE, _("Include message in reply?"))) == MUTT_ABORT)
+ i = query_quadoption(OPT_INCLUDE, _("Include message in reply?"));
+ if (i == MUTT_ABORT)
return -1;
if (i == MUTT_YES)
}
else if (flags & SENDFORWARD)
{
- if ((i = query_quadoption(OPT_MIME_FORWARD, _("Forward as attachment?"))) == MUTT_YES)
+ i = query_quadoption(OPT_MIME_FORWARD, _("Forward as attachment?"));
+ if (i == MUTT_YES)
{
struct Body *last = msg->content;
/* Write out the message in MIME form. */
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((tempfp = safe_fopen(tempfile, "w")) == NULL)
+ tempfp = safe_fopen(tempfile, "w");
+ if (!tempfp)
return -1;
#ifdef USE_SMTP
{
FILE *fp = NULL;
- if ((fp = safe_fopen(data, "a+")) == NULL)
+ fp = safe_fopen(data, "a+");
+ if (!fp)
return;
if (fseek(fp, -1, SEEK_END) >= 0)
{
/* If the user is composing a new message, check to see if there
* are any postponed messages first.
*/
- if ((i = query_quadoption(OPT_RECALL, _("Recall postponed message?"))) == MUTT_ABORT)
+ i = query_quadoption(OPT_RECALL, _("Recall postponed message?"));
+ if (i == MUTT_ABORT)
return rv;
if (i == MUTT_YES)
if (flags & (SENDPOSTPONED | SENDRESEND))
{
- if ((tempfp = safe_fopen(msg->content->filename, "a+")) == NULL)
+ tempfp = safe_fopen(msg->content->filename, "a+");
+ if (!tempfp)
{
mutt_perror(msg->content->filename);
goto cleanup;
return 0;
}
- if ((fpin = fopen(a->filename, "r")) == NULL)
+ fpin = fopen(a->filename, "r");
+ if (!fpin)
{
mutt_debug(1, "write_mime_body: %s no longer exists!\n", a->filename);
mutt_error(_("%s no longer exists!"), a->filename);
ncodes = 0;
for (c = tocodes; c; c = c1 ? c1 + 1 : 0)
{
- if ((c1 = strchr(c, ':')) == c)
+ c1 = strchr(c, ':');
+ if (c1 == c)
continue;
ncodes++;
}
tcode = safe_malloc(ncodes * sizeof(char *));
for (c = tocodes, i = 0; c; c = c1 ? c1 + 1 : 0, i++)
{
- if ((c1 = strchr(c, ':')) == c)
+ c1 = strchr(c, ':');
+ if (c1 == c)
continue;
tcode[i] = mutt_substrdup(c, c1);
}
/* Try each fromcode in turn */
for (c = fromcodes; c; c = c1 ? c1 + 1 : 0)
{
- if ((c1 = strchr(c, ':')) == c)
+ c1 = strchr(c, ':');
+ if (c1 == c)
continue;
fcode = mutt_substrdup(c, c1);
return NULL;
}
- if ((fp = fopen(fname, "r")) == NULL)
+ fp = fopen(fname, "r");
+ if (!fp)
{
mutt_debug(1, "mutt_get_content_info: %s: %s (errno %d).\n", fname,
strerror(errno), errno);
goto bye; /* shouldn't happen */
}
- if ((f = fopen(buf, "r")) != NULL)
+ f = fopen(buf, "r");
+ if (f)
{
found_mimetypes = true;
SKIPWS(ct);
/* position on the next field in this line */
- if ((p = strpbrk(ct, " \t")) == NULL)
+ p = strpbrk(ct, " \t");
+ if (!p)
continue;
*p++ = 0;
SKIPWS(p);
{
/* get the content-type */
- if ((p = strchr(ct, '/')) == NULL)
+ p = strchr(ct, '/');
+ if (!p)
{
/* malformed line, just skip it. */
break;
mutt_substrcpy(subtype, p, q, sizeof(subtype));
- if ((type = mutt_check_mime_type(ct)) == TYPEOTHER)
+ type = mutt_check_mime_type(ct);
+ if (type == TYPEOTHER)
strfcpy(xtype, ct, sizeof(xtype));
cur_sze = sze;
a->force_charset = true;
mutt_mktemp(buff, sizeof(buff));
- if ((s.fpout = safe_fopen(buff, "w")) == NULL)
+ s.fpout = safe_fopen(buff, "w");
+ if (!s.fpout)
{
mutt_perror("fopen");
return;
if (!a->force_charset && !a->noconv)
mutt_delete_parameter("charset", &a->parameter);
- if ((info = mutt_get_content_info(a->filename, a)) == NULL)
+ info = mutt_get_content_info(a->filename, a);
+ if (!info)
return;
set_encoding(a, info);
}
mutt_mktemp(buffer, sizeof(buffer));
- if ((fp = safe_fopen(buffer, "w+")) == NULL)
+ fp = safe_fopen(buffer, "w+");
+ if (!fp)
return NULL;
body = mutt_new_body();
return;
}
- if ((buf = mutt_read_line(buf, &buflen, fp, &dummy, 0)) != NULL)
+ buf = mutt_read_line(buf, &buflen, fp, &dummy, 0);
+ if (buf)
{
if (strchr(buf, '/'))
mutt_parse_content_type(buf, att);
!option(OPT_MIME_TYPE_QUERY_FIRST))
run_mime_type_query(att);
- if ((info = mutt_get_content_info(path, att)) == NULL)
+ info = mutt_get_content_info(path, att);
+ if (!info)
{
mutt_free_body(&att);
return NULL;
*tempfile = safe_strdup(tmp);
}
- if ((pid = fork()) == 0)
+ pid = fork();
+ if (pid == 0)
{
struct sigaction act, oldalrm;
#endif
/* now the second fork() */
- if ((pid = fork()) == 0)
+ pid = fork();
+ if (pid == 0)
{
/* "msg" will be opened as stdin */
if (open(msg, O_RDONLY, 0) < 0)
fp = msg->fp;
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((f = safe_fopen(tempfile, "w")) != NULL)
+ f = safe_fopen(tempfile, "w");
+ if (f)
{
int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
char *msgid_str = NULL;
if (f.magic == MUTT_MMDF || f.magic == MUTT_MBOX)
{
mutt_mktemp(tempfile, sizeof(tempfile));
- if ((tempfp = safe_fopen(tempfile, "w+")) == NULL)
+ tempfp = safe_fopen(tempfile, "w+");
+ if (!tempfp)
{
mutt_perror(tempfile);
mx_close_mailbox(&f, NULL);
onm_flags = MUTT_ADD_FROM;
if (post)
onm_flags |= MUTT_SET_DRAFT;
- if ((msg = mx_open_new_message(&f, hdr, onm_flags)) == NULL)
+ msg = mx_open_new_message(&f, hdr, onm_flags);
+ if (!msg)
{
safe_fclose(&tempfp);
mx_close_mailbox(&f, NULL);
sigaction(SIGTSTP, &act, &oldtstp);
sigaction(SIGCONT, &act, &oldcont);
- if ((thepid = fork()) == 0)
+ thepid = fork();
+ if (thepid == 0)
{
act.sa_flags = 0;
{
cur = tree;
tree = tree->next;
- if ((parent = find_subject(ctx, cur)) != NULL)
+ parent = find_subject(ctx, cur);
+ if (parent)
{
cur->fake_thread = true;
unlink_message(&top, cur);
if (using_refs == 0)
{
/* look at the beginning of in-reply-to: */
- if ((ref = STAILQ_FIRST(&cur->env->in_reply_to)) != NULL)
+ ref = STAILQ_FIRST(&cur->env->in_reply_to);
+ if (ref)
using_refs = 1;
else
{
if (!ref)
break;
- if ((new = hash_find(ctx->thread_hash, ref->data)) == NULL)
+ new = hash_find(ctx->thread_hash, ref->data);
+ if (!new)
{
new = safe_calloc(1, sizeof(struct MuttThread));
hash_insert(ctx->thread_hash, ref->data, new);
return cur->message;
top = cur;
- if ((cur = cur->child) == NULL)
+ cur = cur->child;
+ if (!cur)
return NULL;
while (reverse && cur->next)
for (thread = hdr->thread->parent; thread; thread = thread->parent)
{
- if ((hdr = thread->message) != NULL)
+ hdr = thread->message;
+ if (hdr)
{
parent = hdr;
if (!find_root)
for (t = sbuf; *t; t++)
*t = tolower(*t);
- if ((i = mutt_getvaluebyname(sbuf, UrlMap)) == -1)
+ i = mutt_getvaluebyname(sbuf, UrlMap);
+ if (i == -1)
return U_UNKNOWN;
else
return (enum UrlScheme) i;
{
char *tmp = NULL;
- if ((u->scheme = url_check_scheme(src)) == U_UNKNOWN)
+ u->scheme = url_check_scheme(src);
+ if (u->scheme == U_UNKNOWN)
return -1;
tmp = strchr(src, ':') + 1;
return -1;
/* copy string for safe use of strtok() */
- if ((tmp = safe_strdup(t + 1)) == NULL)
+ tmp = safe_strdup(t + 1);
+ if (!tmp)
return -1;
if ((headers = strchr(tmp, '?')))