From b261094e80c364b117defc25f90527b0ecb8a853 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Wed, 20 Mar 2019 00:30:53 +0000 Subject: [PATCH] ()s on ternary --- addrbook.c | 2 +- bcache.c | 6 +++--- browser.c | 30 +++++++++++++++--------------- conn/sasl.c | 2 +- conn/ssl.c | 2 +- curs_lib.c | 10 +++++----- editmsg.c | 2 +- email/rfc2047.c | 2 +- hdrline.c | 9 +++++---- help.c | 5 +++-- imap/browse.c | 2 +- imap/imap.c | 2 +- index.c | 6 +++--- init.c | 2 +- keymap.c | 4 ++-- maildir/shared.c | 14 +++++++------- menu.c | 6 +++--- mutt/charset.c | 4 ++-- mutt/date.c | 2 +- mutt/mbyte.c | 2 +- mutt/md5.c | 2 +- mutt/path.c | 2 +- mutt/sha1.c | 3 ++- mutt_attach.c | 27 ++++++++++++++------------- mutt_parse.c | 2 +- mutt_thread.c | 5 ++--- mx.c | 2 +- ncrypt/crypt_gpgme.c | 10 +++++----- ncrypt/pgp.c | 2 +- ncrypt/pgpinvoke.c | 3 ++- ncrypt/smime.c | 2 +- nntp/newsrc.c | 2 +- nntp/nntp.c | 2 +- notmuch/mutt_notmuch.c | 2 +- pager.c | 12 ++++++------ pattern.c | 2 +- pop/pop_auth.c | 2 +- recvattach.c | 8 ++++---- rfc1524.c | 2 +- send.c | 6 +++--- sendlib.c | 6 +++--- sort.c | 2 +- 42 files changed, 112 insertions(+), 108 deletions(-) diff --git a/addrbook.c b/addrbook.c index ee961f40f..a14476683 100644 --- a/addrbook.c +++ b/addrbook.c @@ -239,7 +239,7 @@ new_aliases: if ((C_SortAlias & SORT_MASK) != SORT_ORDER) { qsort(alias_table, menu->max, sizeof(struct Alias *), - (C_SortAlias & SORT_MASK) == SORT_ADDRESS ? alias_sort_address : alias_sort_alias); + ((C_SortAlias & SORT_MASK) == SORT_ADDRESS) ? alias_sort_address : alias_sort_alias); } for (i = 0; i < menu->max; i++) diff --git a/bcache.c b/bcache.c index a19af6c63..29194e49c 100644 --- a/bcache.c +++ b/bcache.c @@ -84,7 +84,7 @@ static int bcache_path(struct ConnAccount *account, const char *mailbox, char *d size_t mailboxlen = mutt_str_strlen(mailbox); len = snprintf(dst, dstlen, "%s/%s%s%s", C_MessageCachedir, host, NONULL(mailbox), - (mailboxlen != 0 && mailbox[mailboxlen - 1] == '/') ? "" : "/"); + ((mailboxlen != 0) && (mailbox[mailboxlen - 1] == '/')) ? "" : "/"); mutt_encode_path(dst, dstlen, dst); @@ -293,9 +293,9 @@ int mutt_bcache_exists(struct BodyCache *bcache, const char *id) if (stat(path, &st) < 0) rc = -1; else - rc = S_ISREG(st.st_mode) && st.st_size != 0 ? 0 : -1; + rc = (S_ISREG(st.st_mode) && (st.st_size != 0)) ? 0 : -1; - mutt_debug(LL_DEBUG3, "bcache: exists: '%s': %s\n", path, rc == 0 ? "yes" : "no"); + mutt_debug(LL_DEBUG3, "bcache: exists: '%s': %s\n", path, (rc == 0) ? "yes" : "no"); return rc; } diff --git a/browser.c b/browser.c index 667d9ae51..ae6bf7c22 100644 --- a/browser.c +++ b/browser.c @@ -390,7 +390,7 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c else { time_t tnow = time(NULL); - t_fmt = tnow - folder->ff->mtime < 31536000 ? "%b %d %H:%M" : "%b %d %Y"; + t_fmt = ((tnow - folder->ff->mtime) < 31536000) ? "%b %d %H:%M" : "%b %d %Y"; } if (!do_locales) @@ -418,7 +418,7 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c "@" : (S_ISDIR(folder->ff->mode) ? "/" : - ((folder->ff->mode & S_IXUSR) != 0 ? "*" : ""))) : + (((folder->ff->mode & S_IXUSR) != 0) ? "*" : ""))) : ""); mutt_format_s(buf, buflen, prec, fn); @@ -429,21 +429,21 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c { snprintf(permission, sizeof(permission), "%c%c%c%c%c%c%c%c%c%c", S_ISDIR(folder->ff->mode) ? 'd' : (S_ISLNK(folder->ff->mode) ? 'l' : '-'), - (folder->ff->mode & S_IRUSR) != 0 ? 'r' : '-', - (folder->ff->mode & S_IWUSR) != 0 ? 'w' : '-', - (folder->ff->mode & S_ISUID) != 0 ? + ((folder->ff->mode & S_IRUSR) != 0) ? 'r' : '-', + ((folder->ff->mode & S_IWUSR) != 0) ? 'w' : '-', + ((folder->ff->mode & S_ISUID) != 0) ? 's' : - (folder->ff->mode & S_IXUSR) != 0 ? 'x' : '-', - (folder->ff->mode & S_IRGRP) != 0 ? 'r' : '-', - (folder->ff->mode & S_IWGRP) != 0 ? 'w' : '-', - (folder->ff->mode & S_ISGID) != 0 ? + ((folder->ff->mode & S_IXUSR) != 0) ? 'x' : '-', + ((folder->ff->mode & S_IRGRP) != 0) ? 'r' : '-', + ((folder->ff->mode & S_IWGRP) != 0) ? 'w' : '-', + ((folder->ff->mode & S_ISGID) != 0) ? 's' : - (folder->ff->mode & S_IXGRP) != 0 ? 'x' : '-', - (folder->ff->mode & S_IROTH) != 0 ? 'r' : '-', - (folder->ff->mode & S_IWOTH) != 0 ? 'w' : '-', - (folder->ff->mode & S_ISVTX) != 0 ? + ((folder->ff->mode & S_IXGRP) != 0) ? 'x' : '-', + ((folder->ff->mode & S_IROTH) != 0) ? 'r' : '-', + ((folder->ff->mode & S_IWOTH) != 0) ? 'w' : '-', + ((folder->ff->mode & S_ISVTX) != 0) ? 't' : - (folder->ff->mode & S_IXOTH) != 0 ? 'x' : '-'); + ((folder->ff->mode & S_IXOTH) != 0) ? 'x' : '-'); mutt_format_s(buf, buflen, prec, permission); } #ifdef USE_IMAP @@ -489,7 +489,7 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c "@" : (S_ISDIR(folder->ff->mode) ? "/" : - ((folder->ff->mode & S_IXUSR) != 0 ? "*" : ""))) : + (((folder->ff->mode & S_IXUSR) != 0) ? "*" : ""))) : ""); mutt_format_s(buf, buflen, prec, fn); diff --git a/conn/sasl.c b/conn/sasl.c index dec27d2bf..93e7e340f 100644 --- a/conn/sasl.c +++ b/conn/sasl.c @@ -257,7 +257,7 @@ static int mutt_sasl_cb_authname(void *context, int id, const char **result, uns return SASL_BADPARAM; mutt_debug(LL_DEBUG2, "getting %s for %s:%u\n", - id == SASL_CB_AUTHNAME ? "authname" : "user", account->host, + (id == SASL_CB_AUTHNAME) ? "authname" : "user", account->host, account->port); if (id == SASL_CB_AUTHNAME) diff --git a/conn/ssl.c b/conn/ssl.c index a99c5c98d..f95f06c13 100644 --- a/conn/ssl.c +++ b/conn/ssl.c @@ -422,7 +422,7 @@ static void x509_fingerprint(char *s, int l, X509 *cert, const EVP_MD *(*hashfun for (unsigned int i = 0; i < n; i++) { char ch[8]; - snprintf(ch, sizeof(ch), "%02X%s", md[i], (i % 2 ? " " : "")); + snprintf(ch, sizeof(ch), "%02X%s", md[i], ((i % 2) ? " " : "")); mutt_str_strcat(s, l, ch); } } diff --git a/curs_lib.c b/curs_lib.c index be24dcca1..602a324ac 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -232,7 +232,7 @@ struct Event mutt_getch(void) ret.ch = ch; ret.op = 0; - return ch == ctrl('G') ? err : ret; + return (ch == ctrl('G')) ? err : ret; } /** @@ -354,8 +354,8 @@ enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def) * around the screen in the even the question is wider than the screen, * ensure there is enough room for the answer and truncate the question * to fit. */ - safe_asprintf(&answer_string, " ([%s]/%s): ", def == MUTT_YES ? yes : no, - def == MUTT_YES ? no : yes); + safe_asprintf(&answer_string, " ([%s]/%s): ", (def == MUTT_YES) ? yes : no, + (def == MUTT_YES) ? no : yes); answer_string_wid = mutt_strwidth(answer_string); msg_wid = mutt_strwidth(msg); @@ -445,7 +445,7 @@ enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def) if (def != MUTT_ABORT) { - addstr((char *) (def == MUTT_YES ? yes : no)); + addstr((char *) ((def == MUTT_YES) ? yes : no)); mutt_refresh(); } else @@ -968,7 +968,7 @@ void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, buflen -= k2; } } - w = (int) buflen < min_width ? buflen : min_width; + w = ((int) buflen < min_width) ? buflen : min_width; if (w <= 0) *p = '\0'; else if (justify == FMT_RIGHT) /* right justify */ diff --git a/editmsg.c b/editmsg.c index 2fecc9ff1..d15fc8d51 100644 --- a/editmsg.c +++ b/editmsg.c @@ -82,7 +82,7 @@ static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e) } const CopyHeaderFlags chflags = - CH_NOLEN | ((m->magic == MUTT_MBOX || m->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS); + CH_NOLEN | (((m->magic == MUTT_MBOX) || (m->magic == MUTT_MMDF)) ? 0 : CH_NOSTATUS); rc = mutt_append_message(tmpctx->mailbox, m, e, 0, chflags); int oerrno = errno; diff --git a/email/rfc2047.c b/email/rfc2047.c index da061c822..95dc04b71 100644 --- a/email/rfc2047.c +++ b/email/rfc2047.c @@ -217,7 +217,7 @@ static size_t try_block(const char *d, size_t dlen, const char *fromcode, assert(errno == E2BIG); iconv_close(cd); assert(ib > d); - return (ib - d == dlen) ? dlen : ib - d + 1; + return ((ib - d) == dlen) ? dlen : ib - d + 1; } iconv_close(cd); } diff --git a/hdrline.c b/hdrline.c index 1008423ca..a1023c89c 100644 --- a/hdrline.c +++ b/hdrline.c @@ -762,7 +762,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co p = buf; - cp = (op == 'd' || op == 'D') ? (NONULL(C_DateFormat)) : src; + cp = ((op == 'd') || (op == 'D')) ? (NONULL(C_DateFormat)) : src; bool do_locales; if (*cp == '!') { @@ -773,9 +773,10 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co do_locales = true; size_t len = buflen - 1; - while (len > 0 && (((op == 'd' || op == 'D') && *cp) || - (op == '{' && *cp != '}') || (op == '[' && *cp != ']') || - (op == '(' && *cp != ')') || (op == '<' && *cp != '>'))) + while ((len > 0) && + ((((op == 'd') || (op == 'D')) && *cp) || + ((op == '{') && (*cp != '}')) || ((op == '[') && (*cp != ']')) || + ((op == '(') && (*cp != ')')) || ((op == '<') && (*cp != '>')))) { if (*cp == '%') { diff --git a/help.c b/help.c index b32fd25d1..e08724da6 100644 --- a/help.c +++ b/help.c @@ -299,8 +299,9 @@ static void format_line(FILE *fp, int ismacro, const char *t1, const char *t2, c } else { - const int col_a = MuttIndexWindow->cols > 83 ? (MuttIndexWindow->cols - 32) >> 2 : 12; - col_b = MuttIndexWindow->cols > 49 ? (MuttIndexWindow->cols - 10) >> 1 : 19; + const int col_a = + (MuttIndexWindow->cols > 83) ? (MuttIndexWindow->cols - 32) >> 2 : 12; + col_b = (MuttIndexWindow->cols > 49) ? (MuttIndexWindow->cols - 10) >> 1 : 19; col = pad(fp, mutt_strwidth(t1), col_a); } diff --git a/imap/browse.c b/imap/browse.c index 5511ca35f..af944dff1 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -308,7 +308,7 @@ int imap_browse(char *path, struct BrowserState *state) { char relpath[2]; /* folder may be "/" */ - snprintf(relpath, sizeof(relpath), "%c", n < 0 ? '\0' : adata->delim); + snprintf(relpath, sizeof(relpath), "%c", (n < 0) ? '\0' : adata->delim); if (showparents) add_folder(adata->delim, relpath, true, false, state, true); if (!state->folder) diff --git a/imap/imap.c b/imap/imap.c index c0e88cb06..1ade13cc3 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1622,7 +1622,7 @@ out: mutt_buffer_free(&sync_cmd); imap_mdata_free((void *) &dest_mdata); - return (rc == IMAP_EXEC_SUCCESS ? 0 : -1); + return ((rc == IMAP_EXEC_SUCCESS) ? 0 : -1); } /** diff --git a/index.c b/index.c index 9526214a6..7984967a5 100644 --- a/index.c +++ b/index.c @@ -3309,8 +3309,8 @@ int mutt_index_menu(void) if (C_Resolve) { menu->current = - (op == OP_MAIN_READ_THREAD ? mutt_next_thread(CUR_EMAIL) : - mutt_next_subthread(CUR_EMAIL)); + ((op == OP_MAIN_READ_THREAD) ? mutt_next_thread(CUR_EMAIL) : + mutt_next_subthread(CUR_EMAIL)); if (menu->current == -1) { menu->current = menu->oldcurrent; @@ -3416,7 +3416,7 @@ int mutt_index_menu(void) break; struct EmailList el = STAILQ_HEAD_INITIALIZER(el); el_add_tagged(&el, Context, CUR_EMAIL, tag); - ci_send_message((op == OP_FOLLOWUP ? SEND_REPLY : SEND_FORWARD) | SEND_NEWS, + ci_send_message(((op == OP_FOLLOWUP) ? SEND_REPLY : SEND_FORWARD) | SEND_NEWS, NULL, NULL, Context, &el); el_free(&el); } diff --git a/init.c b/init.c index 66d7d8ca0..b90c5c026 100644 --- a/init.c +++ b/init.c @@ -1155,7 +1155,7 @@ static enum CommandResult parse_group(struct Buffer *buf, struct Buffer *s, if (mutt_addrlist_to_intl(addr, &estr)) { mutt_buffer_printf(err, _("%sgroup: warning: bad IDN '%s'"), - data == 1 ? "un" : "", estr); + (data == 1) ? "un" : "", estr); mutt_addr_free(&addr); FREE(&estr); goto bail; diff --git a/keymap.c b/keymap.c index 6faa94188..58798ef68 100644 --- a/keymap.c +++ b/keymap.c @@ -578,7 +578,7 @@ int km_dokey(int menu) while (true) { - int i = C_Timeout > 0 ? C_Timeout : 60; + int i = (C_Timeout > 0) ? C_Timeout : 60; #ifdef USE_IMAP /* keepalive may need to run more frequently than C_Timeout allows */ if (C_ImapKeepalive) @@ -587,7 +587,7 @@ int km_dokey(int menu) imap_keepalive(); else { - while (C_ImapKeepalive && C_ImapKeepalive < i) + while (C_ImapKeepalive && (C_ImapKeepalive < i)) { mutt_getch_timeout(C_ImapKeepalive * 1000); tmp = mutt_getch(); diff --git a/maildir/shared.c b/maildir/shared.c index 6c1d3e0ca..4cf4b96e9 100644 --- a/maildir/shared.c +++ b/maildir/shared.c @@ -1563,25 +1563,25 @@ FILE *maildir_open_find_message(const char *folder, const char *msg, char **newn maildir_canon_filename(unique, msg); FILE *fp = md_open_find_message(folder, mutt_b2s(unique), - new_hits > cur_hits ? "new" : "cur", newname); + (new_hits > cur_hits) ? "new" : "cur", newname); if (fp || (errno != ENOENT)) { if ((new_hits < UINT_MAX) && (cur_hits < UINT_MAX)) { - new_hits += (new_hits > cur_hits ? 1 : 0); - cur_hits += (new_hits > cur_hits ? 0 : 1); + new_hits += ((new_hits > cur_hits) ? 1 : 0); + cur_hits += ((new_hits > cur_hits) ? 0 : 1); } goto cleanup; } fp = md_open_find_message(folder, mutt_b2s(unique), - new_hits > cur_hits ? "cur" : "new", newname); + (new_hits > cur_hits) ? "cur" : "new", newname); if (fp || (errno != ENOENT)) { if ((new_hits < UINT_MAX) && (cur_hits < UINT_MAX)) { - new_hits += (new_hits > cur_hits ? 0 : 1); - cur_hits += (new_hits > cur_hits ? 1 : 0); + new_hits += ((new_hits > cur_hits) ? 0 : 1); + cur_hits += ((new_hits > cur_hits) ? 1 : 0); } goto cleanup; @@ -1616,7 +1616,7 @@ int maildir_check_empty(const char *path) { /* we do "cur" on the first iteration since it's more likely that we'll * find old messages without having to scan both subdirs */ - snprintf(realpath, sizeof(realpath), "%s/%s", path, iter == 0 ? "cur" : "new"); + snprintf(realpath, sizeof(realpath), "%s/%s", path, (iter == 0) ? "cur" : "new"); dp = opendir(realpath); if (!dp) return -1; diff --git a/menu.c b/menu.c index 7073427f8..d027da5ec 100644 --- a/menu.c +++ b/menu.c @@ -1147,7 +1147,7 @@ static int menu_search(struct Menu *menu, int op) regex_t re; char buf[128]; char *search_buf = - menu->menu >= 0 && menu->menu < MENU_MAX ? SearchBuffers[menu->menu] : NULL; + ((menu->menu >= 0) && (menu->menu < MENU_MAX)) ? SearchBuffers[menu->menu] : NULL; if (!(search_buf && *search_buf) || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE))) { @@ -1166,7 +1166,7 @@ static int menu_search(struct Menu *menu, int op) search_buf = SearchBuffers[menu->menu]; } menu->search_dir = - (op == OP_SEARCH || op == OP_SEARCH_NEXT) ? MUTT_SEARCH_DOWN : MUTT_SEARCH_UP; + ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? MUTT_SEARCH_DOWN : MUTT_SEARCH_UP; } search_dir = (menu->search_dir == MUTT_SEARCH_UP) ? -1 : 1; @@ -1203,7 +1203,7 @@ search_next: if (C_WrapSearch && (wrap++ == 0)) { - rc = search_dir == 1 ? 0 : menu->max - 1; + rc = (search_dir == 1) ? 0 : menu->max - 1; goto search_next; } regfree(&re); diff --git a/mutt/charset.c b/mutt/charset.c index 6182a8c7b..a054c3b48 100644 --- a/mutt/charset.c +++ b/mutt/charset.c @@ -553,9 +553,9 @@ iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, int flags) /* always apply iconv-hooks to suit system's iconv tastes */ tocode2 = mutt_ch_iconv_lookup(tocode1); - tocode2 = (tocode2) ? tocode2 : tocode1; + tocode2 = tocode2 ? tocode2 : tocode1; fromcode2 = mutt_ch_iconv_lookup(fromcode1); - fromcode2 = (fromcode2) ? fromcode2 : fromcode1; + fromcode2 = fromcode2 ? fromcode2 : fromcode1; /* call system iconv with names it appreciates */ cd = iconv_open(tocode2, fromcode2); diff --git a/mutt/date.c b/mutt/date.c index 54966f5e9..8fc550fe1 100644 --- a/mutt/date.c +++ b/mutt/date.c @@ -634,7 +634,7 @@ time_t mutt_date_parse_imap(const char *s) struct tm t; time_t tz; - t.tm_mday = (s[0] == ' ' ? s[1] - '0' : (s[0] - '0') * 10 + (s[1] - '0')); + t.tm_mday = ((s[0] == ' ') ? s[1] - '0' : (s[0] - '0') * 10 + (s[1] - '0')); s += 2; if (*s != '-') return 0; diff --git a/mutt/mbyte.c b/mutt/mbyte.c index d4c79cef5..6bfcb1fee 100644 --- a/mutt/mbyte.c +++ b/mutt/mbyte.c @@ -66,7 +66,7 @@ int mutt_mb_charlen(const char *s, int *width) k = mbrtowc(&wc, s, n, &mbstate); if (width) *width = wcwidth(wc); - return (k == (size_t)(-1) || k == (size_t)(-2)) ? -1 : k; + return ((k == (size_t)(-1)) || (k == (size_t)(-2))) ? -1 : k; } /** diff --git a/mutt/md5.c b/mutt/md5.c index ead2ac3fd..fd2f2b4b6 100644 --- a/mutt/md5.c +++ b/mutt/md5.c @@ -363,7 +363,7 @@ void mutt_md5_process_bytes(const void *buffer, size_t len, struct Md5Ctx *md5ct if (md5ctx->buflen != 0) { size_t left_over = md5ctx->buflen; - size_t add = (128 - left_over) > len ? len : (128 - left_over); + size_t add = ((128 - left_over) > len) ? len : (128 - left_over); memcpy(&((char *) md5ctx->buffer)[left_over], buffer, add); md5ctx->buflen += add; diff --git a/mutt/path.c b/mutt/path.c index c9fdf054d..dc0f668af 100644 --- a/mutt/path.c +++ b/mutt/path.c @@ -431,7 +431,7 @@ int mutt_path_to_absolute(char *path, const char *reference) path_len = sizeof(abs_path) - strlen(path); - mutt_str_strncat(abs_path, sizeof(abs_path), path, path_len > 0 ? path_len : 0); + mutt_str_strncat(abs_path, sizeof(abs_path), path, (path_len > 0) ? path_len : 0); path = realpath(abs_path, path); if (!path && (errno != ENOENT)) diff --git a/mutt/sha1.c b/mutt/sha1.c index cae3af2eb..30a67519f 100644 --- a/mutt/sha1.c +++ b/mutt/sha1.c @@ -236,7 +236,8 @@ void mutt_sha1_final(unsigned char digest[20], struct Sha1Ctx *sha1ctx) for (unsigned int i = 0; i < 8; i++) { finalcount[i] = - (unsigned char) ((sha1ctx->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */ + (unsigned char) ((sha1ctx->count[((i >= 4) ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & + 255); /* Endian independent */ } c = 0200; diff --git a/mutt_attach.c b/mutt_attach.c index 9dab9e283..909ead00f 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -336,18 +336,19 @@ void mutt_check_lookup_list(struct Body *b, char *type, size_t len) if (n != TYPE_OTHER) { snprintf(type, len, "%s/%s", - n == TYPE_AUDIO ? "audio" : - n == TYPE_APPLICATION ? - "application" : - n == TYPE_IMAGE ? - "image" : - n == TYPE_MESSAGE ? - "message" : - n == TYPE_MODEL ? - "model" : - n == TYPE_MULTIPART ? - "multipart" : - n == TYPE_TEXT ? "text" : n == TYPE_VIDEO ? "video" : "other", + (n == TYPE_AUDIO) ? + "audio" : + (n == TYPE_APPLICATION) ? + "application" : + (n == TYPE_IMAGE) ? + "image" : + (n == TYPE_MESSAGE) ? + "message" : + (n == TYPE_MODEL) ? + "model" : + (n == TYPE_MULTIPART) ? + "multipart" : + (n == TYPE_TEXT) ? "text" : (n == TYPE_VIDEO) ? "video" : "other", tmp.subtype); mutt_debug(LL_DEBUG1, "\"%s\" -> %s\n", b->filename, type); } @@ -823,7 +824,7 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, } if ((ctx->mailbox->magic == MUTT_MBOX) || (ctx->mailbox->magic == MUTT_MMDF)) chflags = CH_FROM | CH_UPDATE_LEN; - chflags |= (ctx->mailbox->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE); + chflags |= ((ctx->mailbox->magic == MUTT_MAILDIR) ? CH_NOSTATUS : CH_UPDATE); if ((mutt_copy_message_fp(msg->fp, fp, en, 0, chflags) == 0) && (mx_msg_commit(ctx->mailbox, msg) == 0)) { diff --git a/mutt_parse.c b/mutt_parse.c index 41f4e317b..42a37c1c1 100644 --- a/mutt_parse.c +++ b/mutt_parse.c @@ -203,7 +203,7 @@ static int count_body_parts(struct Body *body, int flags) } } - mutt_debug(LL_DEBUG3, "return %d\n", count < 0 ? 0 : count); + mutt_debug(LL_DEBUG3, "return %d\n", (count < 0) ? 0 : count); return (count < 0) ? 0 : count; } diff --git a/mutt_thread.c b/mutt_thread.c index 4c378213f..29bbfb943 100644 --- a/mutt_thread.c +++ b/mutt_thread.c @@ -811,12 +811,11 @@ static void check_subjects(struct Mailbox *m, bool init) else if (cur->env->real_subj && tmp->message->env->real_subj) { cur->subject_changed = - (mutt_str_strcmp(cur->env->real_subj, tmp->message->env->real_subj) != 0) ? true : false; + (mutt_str_strcmp(cur->env->real_subj, tmp->message->env->real_subj) != 0); } else { - cur->subject_changed = - (cur->env->real_subj || tmp->message->env->real_subj) ? true : false; + cur->subject_changed = (cur->env->real_subj || tmp->message->env->real_subj); } } } diff --git a/mx.c b/mx.c index 5b9c68b49..ecb12c70c 100644 --- a/mx.c +++ b/mx.c @@ -947,7 +947,7 @@ struct Message *mx_msg_open_new(struct Mailbox *m, struct Email *e, MsgOpenFlags msg->flags.flagged = e->flagged; msg->flags.replied = e->replied; msg->flags.read = e->read; - msg->flags.draft = (flags & MUTT_SET_DRAFT) ? true : false; + msg->flags.draft = (flags & MUTT_SET_DRAFT); msg->received = e->received; } diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index dc3455a59..afede861d 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -254,7 +254,7 @@ static const char *parse_version_number(const char *s, int *number) val += *s - '0'; } *number = val; - return val < 0 ? NULL : s; + return (val < 0) ? NULL : s; } /** @@ -344,14 +344,14 @@ static int cmp_version_strings(const char *a, const char *b, int level) level %= 10; a_major = a_minor = a_micro = 0; - a_plvl = parse_version_string(a, &a_major, level > 1 ? &a_minor : NULL, - level > 2 ? &a_micro : NULL); + a_plvl = parse_version_string(a, &a_major, (level > 1) ? &a_minor : NULL, + (level > 2) ? &a_micro : NULL); if (!a_plvl) a_major = a_minor = a_micro = 0; /* Error. */ b_major = b_minor = b_micro = 0; - b_plvl = parse_version_string(b, &b_major, level > 1 ? &b_minor : NULL, - level > 2 ? &b_micro : NULL); + b_plvl = parse_version_string(b, &b_major, (level > 1) ? &b_minor : NULL, + (level > 2) ? &b_micro : NULL); if (!b_plvl) b_major = b_minor = b_micro = 0; diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 247de2b62..0705bb8eb 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -695,7 +695,7 @@ int pgp_class_application_handler(struct Body *m, struct State *s) { struct FgetConv *fc = NULL; int ch; - char *expected_charset = gpgcharset && *gpgcharset ? gpgcharset : "utf-8"; + char *expected_charset = (gpgcharset && *gpgcharset) ? gpgcharset : "utf-8"; mutt_debug(LL_DEBUG3, "pgp: recoding inline from [%s] to [%s]\n", expected_charset, C_Charset); diff --git a/ncrypt/pgpinvoke.c b/ncrypt/pgpinvoke.c index d866506a6..bfeddff0b 100644 --- a/ncrypt/pgpinvoke.c +++ b/ncrypt/pgpinvoke.c @@ -542,7 +542,8 @@ pid_t pgp_invoke_list_keys(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_er pid_t rc = pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd, pgperrfd, 0, NULL, NULL, mutt_b2s(uids), - keyring == PGP_SECRING ? C_PgpListSecringCommand : C_PgpListPubringCommand); + (keyring == PGP_SECRING) ? C_PgpListSecringCommand : + C_PgpListPubringCommand); mutt_buffer_pool_release(&uids); return rc; diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 2f561c652..a467462ad 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -1123,7 +1123,7 @@ static int smime_handle_cert_email(char *certificate, char *mailbox, bool copy, if (mutt_str_startswith(email, mailbox, CASE_IGNORE)) rc = 1; - rc = rc < 0 ? 0 : rc; + rc = (rc < 0) ? 0 : rc; count++; } diff --git a/nntp/newsrc.c b/nntp/newsrc.c index b5e1fe66d..af19bb81d 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -662,7 +662,7 @@ int nntp_active_save_cache(struct NntpAccountData *adata) if (!mdata || mdata->deleted) continue; - if (off + strlen(mdata->group) + (mdata->desc ? strlen(mdata->desc) : 0) + 50 > buflen) + if ((off + strlen(mdata->group) + (mdata->desc ? strlen(mdata->desc) : 0) + 50) > buflen) { buflen *= 2; mutt_mem_realloc(&buf, buflen); diff --git a/nntp/nntp.c b/nntp/nntp.c index 2a38c0ec3..65562afdc 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -437,7 +437,7 @@ static int nntp_attempt_features(struct NntpAccountData *adata) if (!cont && (mutt_str_strcmp(".", adata->overview_fmt + off) == 0)) break; - cont = chunk >= buflen - off ? 1 : 0; + cont = (chunk >= (buflen - off)) ? 1 : 0; off += strlen(adata->overview_fmt + off); if (!cont) { diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 37706c617..7ee9552bc 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -1723,7 +1723,7 @@ void nm_parse_type_from_query(struct NmMboxData *mdata, char *buf) if (mutt_str_strcasestr(buf, variants[i]) != NULL) { // variants[] is setup such that type can be determined via modulo 2. - mdata->query_type = (i % 2) == 0 ? NM_QUERY_TYPE_THREADS : NM_QUERY_TYPE_MESGS; + mdata->query_type = ((i % 2) == 0) ? NM_QUERY_TYPE_THREADS : NM_QUERY_TYPE_MESGS; mutt_str_remall_strcasestr(buf, variants[i]); } diff --git a/pager.c b/pager.c index c59053688..b80ac79ea 100644 --- a/pager.c +++ b/pager.c @@ -1452,7 +1452,7 @@ static int format_line(struct Line **line_info, int n, unsigned char *buf, if (wc == wc1) { - special |= (wc == '_' && special & A_UNDERLINE) ? A_UNDERLINE : A_BOLD; + special |= ((wc == '_') && (special & A_UNDERLINE)) ? A_UNDERLINE : A_BOLD; } else if ((wc == '_') || (wc1 == '_')) { @@ -1951,7 +1951,7 @@ static void pager_custom_redraw(struct Menu *pager_menu) if (IsEmail(rd->extra) && C_PagerIndexLines) { memcpy(rd->index_window, MuttIndexWindow, sizeof(struct MuttWindow)); - rd->index_window->rows = rd->indexlen > 0 ? rd->indexlen - 1 : 0; + rd->index_window->rows = (rd->indexlen > 0) ? rd->indexlen - 1 : 0; if (C_StatusOnTop) { @@ -2174,7 +2174,7 @@ static void pager_custom_redraw(struct Menu *pager_menu) size_t l1 = rd->pager_status_window->cols * MB_LEN_MAX; size_t l2 = sizeof(buf); hfi.email = (IsEmail(rd->extra)) ? rd->extra->email : rd->extra->body->email; - mutt_make_string_info(buf, l1 < l2 ? l1 : l2, rd->pager_status_window->cols, + mutt_make_string_info(buf, (l1 < l2) ? l1 : l2, rd->pager_status_window->cols, NONULL(C_PagerFormat), &hfi, 0); mutt_draw_statusline(rd->pager_status_window->cols, buf, l2); } @@ -3236,9 +3236,9 @@ int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct P CHECK_ATTACH; SendFlags replyflags = - SEND_REPLY | (ch == OP_GROUP_REPLY ? SEND_GROUP_REPLY : 0) | - (ch == OP_GROUP_CHAT_REPLY ? SEND_GROUP_CHAT_REPLY : 0) | - (ch == OP_LIST_REPLY ? SEND_LIST_REPLY : 0); + SEND_REPLY | ((ch == OP_GROUP_REPLY) ? SEND_GROUP_REPLY : 0) | + ((ch == OP_GROUP_CHAT_REPLY) ? SEND_GROUP_CHAT_REPLY : 0) | + ((ch == OP_LIST_REPLY) ? SEND_LIST_REPLY : 0); if (IsMsgAttach(extra)) mutt_attach_reply(extra->fp, extra->email, extra->actx, extra->body, replyflags); diff --git a/pattern.c b/pattern.c index eb9b89d7e..9d6a850e9 100644 --- a/pattern.c +++ b/pattern.c @@ -2525,7 +2525,7 @@ int mutt_search_command(int cur, int op) OptSearchInvalid = false; } - int incr = (OptSearchReverse) ? -1 : 1; + int incr = OptSearchReverse ? -1 : 1; if (op == OP_SEARCH_OPPOSITE) incr = -incr; diff --git a/pop/pop_auth.c b/pop/pop_auth.c index c25ff8023..6e290e6fc 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -314,7 +314,7 @@ static enum PopAuthRes pop_auth_user(struct PopAccountData *adata, const char *m snprintf(buf, sizeof(buf), "PASS %s\r\n", adata->conn->account.pass); ret = pop_query_d(adata, buf, sizeof(buf), /* don't print the password unless we're at the ungodly debugging level */ - C_DebugLevel < MUTT_SOCK_LOG_FULL ? "PASS *\r\n" : NULL); + (C_DebugLevel < MUTT_SOCK_LOG_FULL) ? "PASS *\r\n" : NULL); } switch (ret) diff --git a/recvattach.c b/recvattach.c index a6c47b0b3..a812eafda 100644 --- a/recvattach.c +++ b/recvattach.c @@ -241,7 +241,7 @@ const char *attach_format_str(char *buf, size_t buflen, size_t col, int cols, { snprintf(fmt, sizeof(fmt), "%%%sc", prec); snprintf(buf, buflen, fmt, - aptr->content->type != TYPE_TEXT || aptr->content->noconv ? 'n' : 'c'); + ((aptr->content->type != TYPE_TEXT) || aptr->content->noconv) ? 'n' : 'c'); } else if ((aptr->content->type != TYPE_TEXT) || aptr->content->noconv) optional = 0; @@ -1577,9 +1577,9 @@ void mutt_view_attachments(struct Email *e) { CHECK_ATTACH; - SendFlags flags = SEND_REPLY | (op == OP_GROUP_REPLY ? SEND_GROUP_REPLY : 0) | - (op == OP_GROUP_CHAT_REPLY ? SEND_GROUP_CHAT_REPLY : 0) | - (op == OP_LIST_REPLY ? SEND_LIST_REPLY : 0); + SendFlags flags = SEND_REPLY | ((op == OP_GROUP_REPLY) ? SEND_GROUP_REPLY : 0) | + ((op == OP_GROUP_CHAT_REPLY) ? SEND_GROUP_CHAT_REPLY : 0) | + ((op == OP_LIST_REPLY) ? SEND_LIST_REPLY : 0); mutt_attach_reply(CURATTACH->fp, e, actx, menu->tagprefix ? NULL : CURATTACH->content, flags); menu->redraw = REDRAW_FULL; diff --git a/rfc1524.c b/rfc1524.c index ab0560972..54f644235 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -568,7 +568,7 @@ int rfc1524_expand_filename(const char *nametemplate, const char *oldfile, rmatch = true; for (j = mutt_str_strlen(oldfile) - 1, k = mutt_str_strlen(nametemplate) - 1; - j >= (lmatch ? i : 0) && k >= i + 2; j--, k--) + (j >= (lmatch ? i : 0)) && (k >= (i + 2)); j--, k--) { if (nametemplate[k] != oldfile[j]) { diff --git a/send.c b/send.c index 99d69c876..cc844488c 100644 --- a/send.c +++ b/send.c @@ -2437,9 +2437,9 @@ int ci_send_message(SendFlags flags, struct Email *msg, const char *tempfile, if (!OptNoCurses && !(flags & SEND_MAILX)) { - mutt_message(i != 0 ? _("Sending in background") : - (flags & SEND_NEWS) ? _("Article posted") : /* USE_NNTP */ - _("Mail sent")); + mutt_message((i != 0) ? _("Sending in background") : + (flags & SEND_NEWS) ? _("Article posted") : /* USE_NNTP */ + _("Mail sent")); #ifdef USE_NOTMUCH if (C_NmRecord) nm_record_message(ctx ? ctx->mailbox : NULL, finalpath, cur); diff --git a/sendlib.c b/sendlib.c index af6536b26..1e02a0a0a 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1885,7 +1885,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, if (tag && *tag && (fprintf(fp, "%s%s: ", NONULL(pfx), tag) < 0)) return -1; - col = mutt_str_strlen(tag) + (tag && *tag ? 2 : 0) + mutt_str_strlen(pfx); + col = mutt_str_strlen(tag) + ((tag && *tag) ? 2 : 0) + mutt_str_strlen(pfx); while (p && *p) { @@ -2383,7 +2383,7 @@ int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, fprintf(fp, "User-Agent: NeoMutt/%s%s\n", PACKAGE_VERSION, GitVer); } - return ferror(fp) == 0 ? 0 : -1; + return (ferror(fp) == 0) ? 0 : -1; } /** @@ -2614,7 +2614,7 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf } else { - st = (C_SendmailWait > 0 && errno == EINTR && SigAlrm) ? S_BKG : S_ERR; + st = ((C_SendmailWait > 0) && (errno == EINTR) && SigAlrm) ? S_BKG : S_ERR; if ((C_SendmailWait > 0) && tempfile && *tempfile) { unlink(*tempfile); diff --git a/sort.c b/sort.c index d80b51ee0..59fe22287 100644 --- a/sort.c +++ b/sort.c @@ -260,7 +260,7 @@ static int compare_spam(const void *a, const void *b) (strtod((*ppa)->env->spam->data, &aptr) - strtod((*ppb)->env->spam->data, &bptr)); /* map double into comparison (-1, 0, or 1) */ - result = (difference < 0.0 ? -1 : difference > 0.0 ? 1 : 0); + result = ((difference < 0.0) ? -1 : (difference > 0.0) ? 1 : 0); /* If either aptr or bptr is equal to data, there is no numeric */ /* value for that spam attribute. In this case, compare lexically. */ -- 2.40.0