]> granicus.if.org Git - neomutt/commitdiff
cppcheck: make logic clearer
authorRichard Russon <rich@flatcap.org>
Tue, 3 Apr 2018 12:53:14 +0000 (13:53 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 3 Apr 2018 12:53:14 +0000 (13:53 +0100)
conn/ssl_gnutls.c
copy.c
imap/auth_gss.c
imap/command.c
mbox.c
mutt_account.c
ncrypt/pgp.c
ncrypt/pgpinvoke.c
send.c
thread.c

index bb7ab03edde56c9ee2a5b51ff2755ff753c72eee..ff8096b1149990558a1113be6cca041ae7365dd7 100644 (file)
@@ -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 e96708d6cac422ec64d4bed0b9533b5236cde1cb..7b87703ae22023b0fbe3bfc9bafd8b84e8f34038 100644 (file)
--- 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;
index 45dac29904cd4ed3858a77547f82eb62d21a5f5e..0ace7c0f8db58f60e235a83c897ac1c42b1c8bf3 100644 (file)
@@ -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!) */
index 1e286b9b61d09dcaa5a7ddbc94c961c6fcdec72a..41b5b1f630bc5f0774a285f3b95265820a9264cf 100644 (file)
@@ -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 05754d18b57f768ba7bfbd753a4cc3912c3bf0f4..039102328af9676b5eeeba048f52aff613b308ed 100644 (file)
--- 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);
index a81dfffe092d0fa756c59515631ef876a7626490..6d37421d0fee42291427d183566b04ce9cb880b5 100644 (file)
@@ -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)))
index 2ee6f4c869062320363c24fce45185fa94aab99f..b06cd3c60d619d4d4a359032897232f2e7af07f1 100644 (file)
@@ -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);
index 161559fd06c53afaf7b264643d11c7270001e2a6..9e69245554df84ec0fd5383ed66fdcedce4852bd 100644 (file)
@@ -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 e0959cb656ba4a808584adf57e44d3802ae90518..9b9d7fcf6960b85a382e6ac71e2130644ffa9a27 100644 (file)
--- 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 */
index f8596d2c70137cbbd36c4bf83e5327c887f98db0..96deda6b4b25ae3028d1bccbc3fe29f317f36a81 100644 (file)
--- 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;