From: Richard Russon Date: Fri, 24 Nov 2017 16:49:23 +0000 (+0000) Subject: split ifs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=218ac264d722ffb2d568079828620fe6fc3064c5;p=neomutt split ifs --- diff --git a/commands.c b/commands.c index da758661d..436cd31ef 100644 --- a/commands.c +++ b/commands.c @@ -908,7 +908,8 @@ int mutt_save_message(struct Header *h, int delete, int decode, int decrypt) continue; mutt_message_hook(Context, Context->hdrs[i], MUTT_MESSAGEHOOK); - if ((rc = mutt_save_message_ctx(Context->hdrs[i], delete, decode, decrypt, &ctx) != 0)) + rc = mutt_save_message_ctx(Context->hdrs[i], delete, decode, decrypt, &ctx); + if (rc != 0) break; #ifdef USE_COMPRESSED if (cm) diff --git a/compose.c b/compose.c index 89e585119..ee1effc32 100644 --- a/compose.c +++ b/compose.c @@ -1268,7 +1268,8 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ mutt_str_strfcpy(buf, ENCODING(CURATTACH->content->encoding), sizeof(buf)); if (mutt_get_field("Content-Transfer-Encoding: ", buf, sizeof(buf), 0) == 0 && buf[0]) { - if ((i = mutt_check_encoding(buf)) != ENCOTHER && i != ENCUUENCODED) + i = mutt_check_encoding(buf); + if ((i != ENCOTHER) && (i != ENCUUENCODED)) { CURATTACH->content->encoding = i; menu->redraw = REDRAW_CURRENT | REDRAW_STATUS; diff --git a/copy.c b/copy.c index 3b4301af4..fbcdbabf7 100644 --- a/copy.c +++ b/copy.c @@ -768,8 +768,8 @@ int mutt_copy_message_ctx(FILE *fpout, struct Context *src, struct Header *hdr, msg = mx_open_message(src, hdr->msgno); if (!msg) return -1; - if ((r = mutt_copy_message_fp(fpout, msg->fp, hdr, flags, chflags)) == 0 && - (ferror(fpout) || feof(fpout))) + r = mutt_copy_message_fp(fpout, msg->fp, hdr, flags, chflags); + if ((r == 0) && (ferror(fpout) || feof(fpout))) { mutt_debug(1, "mutt_copy_message failed to detect EOF!\n"); r = -1; diff --git a/curs_main.c b/curs_main.c index c08216e1f..ed6379ce9 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2856,8 +2856,11 @@ int mutt_index_menu(void) if (option(OPT_DELETE_UNTAG)) mutt_thread_set_flag(CURHDR, MUTT_TAG, 0, subthread); 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_INDEX | REDRAW_STATUS; } break; @@ -3082,10 +3085,12 @@ int mutt_index_menu(void) { if (option(OPT_RESOLVE)) { - if ((menu->current = (op == OP_MAIN_READ_THREAD ? - mutt_next_thread(CURHDR) : - mutt_next_subthread(CURHDR))) == -1) + menu->current = (op == OP_MAIN_READ_THREAD ? mutt_next_thread(CURHDR) : + mutt_next_subthread(CURHDR)); + if (menu->current == -1) + { menu->current = menu->oldcurrent; + } else if (menu->menu == MENU_PAGER) { op = OP_DISPLAY_MESSAGE; diff --git a/handler.c b/handler.c index e81b5d256..b0b3e6234 100644 --- a/handler.c +++ b/handler.c @@ -934,7 +934,8 @@ static int is_mmnoask(const char *buf) char tmp[LONG_STRING], *p = NULL, *q = NULL; int lng; - if ((p = getenv("MM_NOASK")) != NULL && *p) + p = getenv("MM_NOASK"); + if (p && *p) { if (mutt_str_strcmp(p, "1") == 0) return 1; diff --git a/imap/auth.c b/imap/auth.c index 59d3ef54c..0c3106199 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -98,7 +98,8 @@ int imap_authenticate(struct ImapData *idata) if (!authenticator->method || (mutt_str_strcasecmp(authenticator->method, method) == 0)) { - if ((r = authenticator->authenticate(idata, method)) != IMAP_AUTH_UNAVAIL) + r = authenticator->authenticate(idata, method); + if (r != IMAP_AUTH_UNAVAIL) { FREE(&methods); return r; @@ -119,7 +120,8 @@ int imap_authenticate(struct ImapData *idata) while (authenticator->authenticate) { - if ((r = authenticator->authenticate(idata, NULL)) != IMAP_AUTH_UNAVAIL) + r = authenticator->authenticate(idata, NULL); + if (r != IMAP_AUTH_UNAVAIL) return r; authenticator++; } diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 7059710e1..6d9376a59 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -229,8 +229,11 @@ enum ImapAuthRes imap_auth_sasl(struct ImapData *idata, const char *method) } while (irc != IMAP_CMD_OK) - if ((irc = imap_cmd_step(idata)) != IMAP_CMD_CONTINUE) + { + irc = imap_cmd_step(idata); + if (irc != IMAP_CMD_CONTINUE) break; + } if (rc != SASL_OK) goto bail; diff --git a/init.c b/init.c index 51cbeb07a..b3ebe5bdc 100644 --- a/init.c +++ b/init.c @@ -2021,7 +2021,8 @@ static int parse_my_hdr(struct Buffer *buf, struct Buffer *s, char *p = NULL; mutt_extract_token(buf, s, MUTT_TOKEN_SPACE | MUTT_TOKEN_QUOTE); - if ((p = strpbrk(buf->data, ": \t")) == NULL || *p != ':') + p = strpbrk(buf->data, ": \t"); + if (!p || (*p != ':')) { mutt_str_strfcpy(err->data, _("invalid header field"), err->dsize); return -1; diff --git a/keymap.c b/keymap.c index f7f4ba84a..4198a10bf 100644 --- a/keymap.c +++ b/keymap.c @@ -1218,7 +1218,8 @@ int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, mutt_extract_token(buf, s, 0); function = buf->data; - if ((bindings = km_get_table(CurrentMenu)) == NULL && CurrentMenu != MENU_PAGER) + bindings = km_get_table(CurrentMenu); + if (!bindings && (CurrentMenu != MENU_PAGER)) bindings = OpGeneric; ops[nops] = get_op(bindings, function, mutt_str_strlen(function)); diff --git a/mbox.c b/mbox.c index c54d74f3e..45ddd8c85 100644 --- a/mbox.c +++ b/mbox.c @@ -1058,7 +1058,8 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) } /* Check to make sure that the file hasn't changed on disk */ - if ((i = mbox_check_mailbox(ctx, index_hint)) == MUTT_NEW_MAIL || i == MUTT_REOPENED) + i = mbox_check_mailbox(ctx, index_hint); + if ((i == MUTT_NEW_MAIL) || (i == MUTT_REOPENED)) { /* new mail arrived, or mailbox reopened */ need_sort = i; @@ -1071,8 +1072,8 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) /* Create a temporary file to write the new version of the mailbox in. */ mutt_mktemp(tempfile, sizeof(tempfile)); - if ((i = open(tempfile, O_WRONLY | O_EXCL | O_CREAT, 0600)) == -1 || - (fp = fdopen(i, "w")) == NULL) + i = open(tempfile, O_WRONLY | O_EXCL | O_CREAT, 0600); + if ((i == -1) || (fp = fdopen(i, "w")) == NULL) { if (-1 != i) { diff --git a/mh.c b/mh.c index 139487d7e..cceeb5552 100644 --- a/mh.c +++ b/mh.c @@ -702,7 +702,8 @@ void maildir_parse_flags(struct Header *h, const char *path) h->read = false; h->replied = false; - if ((p = strrchr(path, ':')) != NULL && (mutt_str_strncmp(p + 1, "2,", 2) == 0)) + p = strrchr(path, ':'); + if (p && (mutt_str_strncmp(p + 1, "2,", 2) == 0)) { p += 3; @@ -2219,7 +2220,8 @@ static int mh_check_mailbox(struct Context *ctx, int *index_hint) /* create .mh_sequences when there isn't one. */ snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->path); - if ((i = stat(buf, &st_cur)) == -1 && errno == ENOENT) + i = stat(buf, &st_cur); + if ((i == -1) && (errno == ENOENT)) { char *tmp = NULL; FILE *fp = NULL; diff --git a/mutt/mbyte.c b/mutt/mbyte.c index 2620522a4..55e4e2a8a 100644 --- a/mutt/mbyte.c +++ b/mutt/mbyte.c @@ -254,8 +254,11 @@ void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen) /* First convert directly into the destination buffer */ memset(&st, 0, sizeof(st)); for (; slen && dlen >= MB_LEN_MAX; dest += k, dlen -= k, src++, slen--) - if ((k = wcrtomb(dest, *src, &st)) == (size_t)(-1)) + { + k = wcrtomb(dest, *src, &st); + if (k == (size_t)(-1)) break; + } /* If this works, we can stop now */ if (dlen >= MB_LEN_MAX) @@ -270,8 +273,11 @@ void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen) char *p = buf; for (; slen && p - buf < dlen; p += k, src++, slen--) - if ((k = wcrtomb(p, *src, &st)) == (size_t)(-1)) + { + k = wcrtomb(p, *src, &st); + if (k == (size_t)(-1)) break; + } p += wcrtomb(p, 0, &st); /* If it fits into the destination buffer, we can stop now */ diff --git a/muttlib.c b/muttlib.c index a306b4f18..354f7a9e3 100644 --- a/muttlib.c +++ b/muttlib.c @@ -589,7 +589,8 @@ void mutt_pretty_mailbox(char *s, size_t buflen) else if (strstr(p, "..") && (scheme == U_UNKNOWN || scheme == U_FILE) && realpath(p, tmp)) mutt_str_strfcpy(p, tmp, buflen - (p - s)); - if ((mutt_str_strncmp(s, Folder, (len = mutt_str_strlen(Folder))) == 0) && s[len] == '/') + len = mutt_str_strlen(Folder); + if ((mutt_str_strncmp(s, Folder, len) == 0) && s[len] == '/') { *s++ = '='; memmove(s, s + len, mutt_str_strlen(s + len) + 1); diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 705d61f79..723c4c126 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -421,7 +421,8 @@ int pgp_application_pgp_handler(struct Body *m, struct State *s) size_t l = 0; FREE(&gpgcharset); gpgcharset = mutt_str_strdup(buf + 9); - if ((l = mutt_str_strlen(gpgcharset)) > 0 && gpgcharset[l - 1] == '\n') + l = mutt_str_strlen(gpgcharset); + if ((l > 0) && (gpgcharset[l - 1] == '\n')) gpgcharset[l - 1] = 0; if (!mutt_check_charset(gpgcharset, 0)) mutt_str_replace(&gpgcharset, "UTF-8"); diff --git a/ncrypt/pgpkey.c b/ncrypt/pgpkey.c index 619b70d93..301900149 100644 --- a/ncrypt/pgpkey.c +++ b/ncrypt/pgpkey.c @@ -959,7 +959,8 @@ struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, enum PgpRing keyrin size_t l; const char *ps = NULL, *pl = NULL, *pfcopy = NULL, *phint = NULL; - if ((l = mutt_str_strlen(p)) && p[l - 1] == '!') + l = mutt_str_strlen(p); + if ((l > 0) && (p[l - 1] == '!')) p[l - 1] = 0; mutt_message(_("Looking for keys matching \"%s\"..."), p); diff --git a/pager.c b/pager.c index 47736413c..943132ff7 100644 --- a/pager.c +++ b/pager.c @@ -895,7 +895,8 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n, /* don't consider line endings part of the buffer * for regex matching */ - if ((nl = mutt_str_strlen(buf)) > 0 && buf[nl - 1] == '\n') + nl = mutt_str_strlen(buf); + if ((nl > 0) && (buf[nl - 1] == '\n')) buf[nl - 1] = 0; i = 0; diff --git a/parse.c b/parse.c index c815ae288..a555ce7c3 100644 --- a/parse.c +++ b/parse.c @@ -86,7 +86,8 @@ char *mutt_read_rfc822_line(FILE *f, char *line, size_t *linelen) * it begins with a non-space */ /* check to see if the next line is a continuation line */ - if ((ch = fgetc(f)) != ' ' && ch != '\t') + ch = fgetc(f); + if ((ch != ' ') && (ch != '\t')) { ungetc(ch, f); return line; /* next line is a separate header field or EOH */ @@ -1183,7 +1184,8 @@ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr, line = mutt_read_rfc822_line(f, line, &linelen); if (*line == '\0') break; - if ((p = strpbrk(line, ": \t")) == NULL || *p != ':') + p = strpbrk(line, ": \t"); + if (!p || (*p != ':')) { char return_path[LONG_STRING]; time_t t; diff --git a/pattern.c b/pattern.c index 1abf3701a..8c4f94e2c 100644 --- a/pattern.c +++ b/pattern.c @@ -1047,7 +1047,8 @@ static int msg_search(struct Context *ctx, struct Pattern *pat, int msgno) { if (pat->op == MUTT_HEADER) { - if (*(buf = mutt_read_rfc822_line(fp, buf, &blen)) == '\0') + buf = mutt_read_rfc822_line(fp, buf, &blen); + if (*buf == '\0') break; } else if (fgets(buf, blen - 1, fp) == NULL) diff --git a/resize.c b/resize.c index d36d2272d..08a02d640 100644 --- a/resize.c +++ b/resize.c @@ -62,12 +62,14 @@ void mutt_resize_screen(void) } if (SLtt_Screen_Rows <= 0) { - if ((cp = getenv("LINES")) != NULL && mutt_str_atoi(cp, &SLtt_Screen_Rows) < 0) + cp = getenv("LINES"); + if (cp && (mutt_str_atoi(cp, &SLtt_Screen_Rows) < 0)) SLtt_Screen_Rows = 24; } if (SLtt_Screen_Cols <= 0) { - if ((cp = getenv("COLUMNS")) != NULL && mutt_str_atoi(cp, &SLtt_Screen_Cols) < 0) + cp = getenv("COLUMNS"); + if (cp && (mutt_str_atoi(cp, &SLtt_Screen_Cols) < 0)) SLtt_Screen_Cols = 80; } #ifdef USE_SLANG_CURSES