From: Richard Russon Date: Tue, 3 Apr 2018 12:53:14 +0000 (+0100) Subject: cppcheck: make logic clearer X-Git-Tag: neomutt-20180512~65^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0248ea22ab26e0a8278ea513d4a6ea47f02d04ea;p=neomutt cppcheck: make logic clearer --- diff --git a/conn/ssl_gnutls.c b/conn/ssl_gnutls.c index bb7ab03ed..ff8096b11 100644 --- a/conn/ssl_gnutls.c +++ b/conn/ssl_gnutls.c @@ -272,7 +272,7 @@ static void tls_fingerprint(gnutls_digest_algorithm_t algo, char *s, int l, for (int i = 0; i < (int) n; i++) { char ch[8]; - snprintf(ch, 8, "%02X%s", md[i], (i % 2 ? " " : "")); + snprintf(ch, 8, "%02X%s", md[i], ((i % 2) ? " " : "")); mutt_str_strcat(s, l, ch); } s[2 * n + n / 2 - 1] = '\0'; /* don't want trailing space */ diff --git a/copy.c b/copy.c index e96708d6c..7b87703ae 100644 --- a/copy.c +++ b/copy.c @@ -320,7 +320,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, if (flags & (CH_DECODE | CH_PREFIX)) { - if (mutt_write_one_header(out, 0, headers[x], flags & CH_PREFIX ? prefix : 0, + if (mutt_write_one_header(out, 0, headers[x], (flags & CH_PREFIX) ? prefix : 0, mutt_window_wrap_cols(MuttIndexWindow, Wrap), flags) == -1) { error = true; diff --git a/imap/auth_gss.c b/imap/auth_gss.c index 45dac2990..0ace7c0f8 100644 --- a/imap/auth_gss.c +++ b/imap/auth_gss.c @@ -250,9 +250,9 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) buf_size = ntohl(*((long *) send_token.value)); gss_release_buffer(&min_stat, &send_token); mutt_debug(2, "Unwrapped security level flags: %c%c%c\n", - server_conf_flags & GSS_AUTH_P_NONE ? 'N' : '-', - server_conf_flags & GSS_AUTH_P_INTEGRITY ? 'I' : '-', - server_conf_flags & GSS_AUTH_P_PRIVACY ? 'P' : '-'); + (server_conf_flags & GSS_AUTH_P_NONE) ? 'N' : '-', + (server_conf_flags & GSS_AUTH_P_INTEGRITY) ? 'I' : '-', + (server_conf_flags & GSS_AUTH_P_PRIVACY) ? 'P' : '-'); mutt_debug(2, "Maximum GSS token size is %ld\n", buf_size); /* agree to terms (hack!) */ diff --git a/imap/command.c b/imap/command.c index 1e286b9b6..41b5b1f63 100644 --- a/imap/command.c +++ b/imap/command.c @@ -198,7 +198,7 @@ static int cmd_start(struct ImapData *idata, const char *cmdstr, int flags) return IMAP_CMD_BAD; rc = mutt_socket_write_d(idata->conn, idata->cmdbuf->data, -1, - flags & IMAP_CMD_PASS ? IMAP_LOG_PASS : IMAP_LOG_CMD); + (flags & IMAP_CMD_PASS) ? IMAP_LOG_PASS : IMAP_LOG_CMD); idata->cmdbuf->dptr = idata->cmdbuf->data; /* unidle when command queue is flushed */ diff --git a/mbox.c b/mbox.c index 05754d18b..039102328 100644 --- a/mbox.c +++ b/mbox.c @@ -471,7 +471,7 @@ static int mbox_open_mailbox(struct Context *ctx) static int mbox_open_mailbox_append(struct Context *ctx, int flags) { - ctx->fp = mutt_file_fopen(ctx->path, flags & MUTT_NEWFOLDER ? "w" : "a"); + ctx->fp = mutt_file_fopen(ctx->path, (flags & MUTT_NEWFOLDER) ? "w" : "a"); if (!ctx->fp) { mutt_perror(ctx->path); diff --git a/mutt_account.c b/mutt_account.c index a81dfffe0..6d37421d0 100644 --- a/mutt_account.c +++ b/mutt_account.c @@ -294,7 +294,7 @@ int mutt_account_getpass(struct Account *account) else { snprintf(prompt, sizeof(prompt), _("Password for %s@%s: "), - account->flags & MUTT_ACCT_LOGIN ? account->login : account->user, + (account->flags & MUTT_ACCT_LOGIN) ? account->login : account->user, account->host); account->pass[0] = '\0'; if (mutt_get_password(prompt, account->pass, sizeof(account->pass))) diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 2ee6f4c86..b06cd3c60 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -1629,7 +1629,7 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis b->type = TYPETEXT; b->subtype = mutt_str_strdup("plain"); - mutt_param_set(&b->parameter, "x-action", flags & ENCRYPT ? "pgp-encrypted" : "pgp-signed"); + mutt_param_set(&b->parameter, "x-action", (flags & ENCRYPT) ? "pgp-encrypted" : "pgp-signed"); mutt_param_set(&b->parameter, "charset", send_charset); b->filename = mutt_str_strdup(pgpoutfile); diff --git a/ncrypt/pgpinvoke.c b/ncrypt/pgpinvoke.c index 161559fd0..9e6924555 100644 --- a/ncrypt/pgpinvoke.c +++ b/ncrypt/pgpinvoke.c @@ -226,8 +226,8 @@ pid_t pgp_invoke_traditional(FILE **pgpin, FILE **pgpout, FILE **pgperr, { if (flags & ENCRYPT) return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - flags & SIGN ? 1 : 0, fname, NULL, uids, - flags & SIGN ? PgpEncryptSignCommand : PgpEncryptOnlyCommand); + (flags & SIGN) ? 1 : 0, fname, NULL, uids, + (flags & SIGN) ? PgpEncryptSignCommand : PgpEncryptOnlyCommand); else return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, 1, fname, NULL, NULL, PgpClearSignCommand); diff --git a/send.c b/send.c index e0959cb65..9b9d7fcf6 100644 --- a/send.c +++ b/send.c @@ -1803,7 +1803,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, fcc_error = false; /* reset value since we may have failed before */ mutt_pretty_mailbox(fcc, sizeof(fcc)); i = mutt_compose_menu(msg, fcc, sizeof(fcc), cur, - (flags & SENDNOFREEHEADER ? MUTT_COMPOSE_NOFREEHEADER : 0)); + ((flags & SENDNOFREEHEADER) ? MUTT_COMPOSE_NOFREEHEADER : 0)); if (i == -1) { /* abort */ diff --git a/thread.c b/thread.c index f8596d2c7..96deda6b4 100644 --- a/thread.c +++ b/thread.c @@ -107,7 +107,7 @@ static int need_display_subject(struct Context *ctx, struct Header *hdr) static void linearize_tree(struct Context *ctx) { struct MuttThread *tree = ctx->tree; - struct Header **array = ctx->hdrs + (Sort & SORT_REVERSE ? ctx->msgcount - 1 : 0); + struct Header **array = ctx->hdrs + ((Sort & SORT_REVERSE) ? ctx->msgcount - 1 : 0); while (tree) { @@ -115,7 +115,7 @@ static void linearize_tree(struct Context *ctx) tree = tree->child; *array = tree->message; - array += Sort & SORT_REVERSE ? -1 : 1; + array += (Sort & SORT_REVERSE) ? -1 : 1; if (tree->child) tree = tree->child;