Split 'if' statements that combine an assignment with a test.
e.g. from:
if ((rc = mutt_socket_readln(buf, bufsize, conn)) < 0)
To:
rc = mutt_socket_readln(buf, bufsize, conn);
if (rc < 0)
This makes the statements a little easier to read and debug.
int rv = 0;
if (outfile && *outfile)
- if ((out = safe_open(outfile, O_CREAT | O_EXCL | O_WRONLY)) < 0)
+ {
+ out = safe_open(outfile, O_CREAT | O_EXCL | O_WRONLY);
+ if (out < 0)
{
mutt_perror("open");
return 0;
}
+ }
mutt_endwin(NULL);
return 0;
}
- if ((thepid = mutt_create_filter(command, &fpout, NULL, NULL)) < 0)
+ thepid = mutt_create_filter(command, &fpout, NULL, NULL);
+ if (thepid < 0)
{
mutt_perror(_("Can't create filter"));
rfc1524_free_entry(&entry);
mutt_debug(2, "successfully opened %s read-only\n", newfile);
mutt_endwin(NULL);
- if ((thepid = mutt_create_filter(NONULL(PrintCommand), &fpout, NULL, NULL)) < 0)
+ thepid = mutt_create_filter(NONULL(PrintCommand), &fpout, NULL, NULL);
+ if (thepid < 0)
{
mutt_perror(_("Can't create filter"));
goto bail0;
}
mutt_endwin(NULL);
- if ((thepid = mutt_create_filter(cmd, &fpout, NULL, NULL)) < 0)
+ thepid = mutt_create_filter(cmd, &fpout, NULL, NULL);
+ if (thepid < 0)
{
mutt_perror(_("Can't create filter process"));
return 1;
{
mutt_message_hook(Context, Context->hdrs[Context->v2r[i]], MUTT_MESSAGEHOOK);
mutt_endwin(NULL);
- if ((thepid = mutt_create_filter(cmd, &fpout, NULL, NULL)) < 0)
+ thepid = mutt_create_filter(cmd, &fpout, NULL, NULL);
+ if (thepid < 0)
{
mutt_perror(_("Can't create filter process"));
return 1;
else
{
mutt_endwin(NULL);
- if ((thepid = mutt_create_filter(cmd, &fpout, NULL, NULL)) < 0)
+ thepid = mutt_create_filter(cmd, &fpout, NULL, NULL);
+ if (thepid < 0)
{
mutt_perror(_("Can't create filter process"));
return 1;
CURHDR->index :
0;
- if ((check = mx_check_mailbox(Context, &index_hint)) < 0)
+ check = mx_check_mailbox(Context, &index_hint);
+ if (check < 0)
{
if (!Context->path)
{
* set CurrentMenu incorrectly when we return back to the index menu. */
menu->menu = MENU_MAIN;
- if ((op = mutt_display_message(CURHDR)) < 0)
+ op = mutt_display_message(CURHDR);
+ if (op < 0)
{
unset_option(OPT_NEED_RESORT);
break;
CHECK_MSGCOUNT;
CHECK_VISIBLE;
- if ((menu->current = mutt_parent_message(Context, CURHDR, op == OP_MAIN_ROOT_MESSAGE)) < 0)
+ menu->current = mutt_parent_message(Context, CURHDR, op == OP_MAIN_ROOT_MESSAGE);
+ if (menu->current < 0)
{
menu->current = menu->oldcurrent;
}
}
mutt_refresh();
- if ((ch = km_dokey(MENU_EDITOR)) < 0)
+ ch = km_dokey(MENU_EDITOR);
+ if (ch < 0)
{
rv = (SigWinch && ch == -2) ? 1 : -1;
goto bye;
}
/* now we should be on the month. */
- if ((tm.tm_mon = mutt_check_month(s)) < 0)
+ tm.tm_mon = mutt_check_month(s);
+ if (tm.tm_mon < 0)
return 0;
/* day */
{
int rc;
- if ((rc = cmd_start(idata, cmdstr, flags)) < 0)
+ rc = cmd_start(idata, cmdstr, flags);
+ if (rc < 0)
{
cmd_handle_fatal(idata);
return -1;
return -1;
}
- if ((rc = imap_exec(idata, buf, IMAP_CMD_FAIL_OK)) < 0)
+ rc = imap_exec(idata, buf, IMAP_CMD_FAIL_OK);
+ if (rc < 0)
{
mutt_debug(1, "imap_access: Can't check STATUS of %s\n", mbox);
return rc;
return 0;
snprintf(buf, sizeof(buf), "+FLAGS.SILENT (%s)", name);
- if ((rc = imap_exec_msgset(idata, "UID STORE", buf, flag, 1, 0)) < 0)
+ rc = imap_exec_msgset(idata, "UID STORE", buf, flag, 1, 0);
+ if (rc < 0)
return rc;
count += rc;
buf[0] = '-';
- if ((rc = imap_exec_msgset(idata, "UID STORE", buf, flag, 1, 1)) < 0)
+ rc = imap_exec_msgset(idata, "UID STORE", buf, flag, 1, 1);
+ if (rc < 0)
return rc;
count += rc;
{
int clauses;
- if ((clauses = do_search(pat->child, 1)) > 0)
+ clauses = do_search(pat->child, 1);
+ if (clauses > 0)
{
const struct Pattern *clause = pat->child;
if (rc != IMAP_CMD_CONTINUE)
break;
- if ((mfhrc = msg_fetch_header(ctx, &h, idata->buf, NULL)) < 0)
+ mfhrc = msg_fetch_header(ctx, &h, idata->buf, NULL);
+ if (mfhrc < 0)
continue;
if (!h.data->uid)
if (rc != IMAP_CMD_CONTINUE)
break;
- if ((mfhrc = msg_fetch_header(ctx, &h, idata->buf, fp)) < 0)
+ mfhrc = msg_fetch_header(ctx, &h, idata->buf, fp);
+ if (mfhrc < 0)
continue;
if (!ftello(fp))
goto out;
}
}
- if ((rc = imap_exec(idata, cmd.data, IMAP_CMD_QUEUE)) < 0)
+ rc = imap_exec(idata, cmd.data, IMAP_CMD_QUEUE);
+ if (rc < 0)
{
mutt_debug(1, "could not queue copy\n");
goto out;
mx->account.flags |= MUTT_ACCT_USER;
}
- if ((n = sscanf(tmp, "%127[^:/]%127s", mx->account.host, tmp)) < 1)
+ n = sscanf(tmp, "%127[^:/]%127s", mx->account.host, tmp);
+ if (n < 1)
{
mutt_debug(1, "imap_parse_path: NULL host in %s\n", path);
FREE(&mx->mbox);
return -1;
}
cmd = mutt_substrdup(tok->dptr, pc);
- if ((pid = mutt_create_filter(cmd, NULL, &fp, NULL)) < 0)
+ pid = mutt_create_filter(cmd, NULL, &fp, NULL);
+ if (pid < 0)
{
mutt_debug(1, "mutt_get_token: unable to fork command: %s\n", cmd);
FREE(&cmd);
;
if (pp >= s)
{
- if ((i = parse_fkey(pp)) > 0)
+ i = parse_fkey(pp);
+ if (i > 0)
{
generic_push(KEY_F(i), 0);
p = pp - 1;
while (sent < len)
{
- if ((rc = conn->conn_write(conn, buf + sent, len - sent)) < 0)
+ rc = conn->conn_write(conn, buf + sent, len - sent);
+ if (rc < 0)
{
mutt_debug(1, "mutt_socket_write: error writing (%s), closing socket\n",
strerror(errno));
if (!bio)
return;
ERR_print_errors(bio);
- if ((buflen = BIO_get_mem_data(bio, &buf)) > 0)
+ buflen = BIO_get_mem_data(bio, &buf);
+ if (buflen > 0)
{
output = safe_malloc(buflen + 1);
memcpy(output, buf, buflen);
return -1;
}
- if ((err = gnutls_priority_set_direct(data->state, priority, NULL)) < 0)
+ err = gnutls_priority_set_direct(data->state, priority, NULL);
+ if (err < 0)
{
mutt_error("gnutls_priority_set_direct(%s): %s", priority, gnutls_strerror(err));
mutt_sleep(2);
* %*X: right justify to EOL, right takes precedence */
int soft = ch == '*';
int pl, pw;
- if ((pl = mutt_charlen(src, &pw)) <= 0)
+ pl = mutt_charlen(src, &pw);
+ if (pl <= 0)
pl = pw = 1;
/* see if there's room to add content, else ignore */
{
/* pad to EOL */
int pl, pw, c;
- if ((pl = mutt_charlen(src, &pw)) <= 0)
+ pl = mutt_charlen(src, &pw);
+ if (pl <= 0)
pl = pw = 1;
/* see if there's room to add content, else ignore */
{
int tmp, w;
/* in case of error, simply copy byte */
- if ((tmp = mutt_charlen(src, &w)) < 0)
+ tmp = mutt_charlen(src, &w);
+ if (tmp < 0)
tmp = w = 1;
if (tmp > 0 && wlen + tmp < destlen)
{
return;
}
- if ((end = ftello(in) - strlen(line)) < start)
+ end = ftello(in) - strlen(line);
+ if (end < start)
{
mutt_debug(1, "pgp_dearmor: end < start???\n");
return;
{
if (hdr)
{
- if ((hdr->content->length = atol(p)) < 0)
+ hdr->content->length = atol(p);
+ if (hdr->content->length < 0)
hdr->content->length = -1;
}
matched = 1;
mutt_expand_file_fmt(cmd, sizeof(cmd), QueryCommand, s);
- if ((thepid = mutt_create_filter(cmd, NULL, &fp, NULL)) < 0)
+ thepid = mutt_create_filter(cmd, NULL, &fp, NULL);
+ if (thepid < 0)
{
mutt_debug(1, "unable to fork command: %s\n", cmd);
return 0;
if (flags == SENDPOSTPONED)
{
- if ((flags = mutt_get_postponed(ctx, msg, &cur, fcc, sizeof(fcc))) < 0)
+ flags = mutt_get_postponed(ctx, msg, &cur, fcc, sizeof(fcc));
+ if (flags < 0)
goto cleanup;
#ifdef USE_NNTP
/*
mutt_expand_file_fmt(cmd, sizeof(cmd), MimeTypeQueryCommand, att->filename);
- if ((thepid = mutt_create_filter(cmd, NULL, &fp, &fperr)) < 0)
+ thepid = mutt_create_filter(cmd, NULL, &fp, &fperr);
+ if (thepid < 0)
{
mutt_error(_("Error running \"%s\"!"), cmd);
return;
/* find maximum line width in current header */
if (p)
*p = 0;
- if ((w = my_width(line, 0, flags)) > max)
+ w = my_width(line, 0, flags);
+ if (w > max)
max = w;
if (p)
*p = '\n';
{
if (mutt_socket_write(conn, buf) < 0)
goto fail;
- if ((rc = mutt_socket_readln(buf, bufsize, conn)) < 0)
+ rc = mutt_socket_readln(buf, bufsize, conn);
+ if (rc < 0)
goto fail;
if (!valid_smtp_code(buf, rc, &rc))
goto fail;
char mb[MB_LEN_MAX] = "";
int rc;
- if ((rc = wcrtomb(mb, wc, NULL)) < 0)
+ rc = wcrtomb(mb, wc, NULL);
+ if (rc < 0)
return rc;
if (fputs(mb, s->fpout) == EOF)
return -1;