]> granicus.if.org Git - neomutt/commitdiff
compare integers against 0
authorRichard Russon <rich@flatcap.org>
Thu, 17 Jan 2019 19:58:57 +0000 (19:58 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 8 Feb 2019 17:03:31 +0000 (17:03 +0000)
compose.c
imap/imap.c
index.c
mx.c
postpone.c
send.c
sidebar.c
sort.c
status.c

index 70b832373960aa7e0be71b1aef1c84a7d1fe3be4..b4fcef89d68e0b8ad78f0655cf64703767ee2473 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -1459,7 +1459,7 @@ int mutt_compose_menu(struct Email *msg, char *fcc, size_t fcclen, struct Email
           break;
         }
 
-        if (!ctx->mailbox->msg_count)
+        if (ctx->mailbox->msg_count == 0)
         {
           mx_mbox_close(&ctx);
           mutt_error(_("No messages in that folder"));
index b752b97951f3b2dd51ebdadb2a3958f94b7261d1..4d32c0499577df354db697d2985e8356426a0459 100644 (file)
@@ -196,7 +196,7 @@ static int make_msg_set(struct Mailbox *m, struct Buffer *buf, int flag,
 
   struct Email **emails = m->emails;
 
-  for (n = *pos; n < m->msg_count && buf->dptr - buf->data < IMAP_MAX_CMDLEN; n++)
+  for (n = *pos; (n < m->msg_count) && ((buf->dptr - buf->data) < IMAP_MAX_CMDLEN); n++)
   {
     bool match = false; /* whether current message matches flag condition */
     /* don't include pending expunged messages */
@@ -250,7 +250,7 @@ static int make_msg_set(struct Mailbox *m, struct Buffer *buf, int flag,
           mutt_buffer_add_printf(buf, ",%u", imap_edata_get(emails[n])->uid);
       }
       /* tie up if the last message also matches */
-      else if (n == m->msg_count - 1)
+      else if (n == (m->msg_count - 1))
         mutt_buffer_add_printf(buf, ":%u", imap_edata_get(emails[n])->uid);
     }
     /* End current set if message doesn't match or we've reached the end
@@ -2247,7 +2247,7 @@ static int imap_mbox_close(struct Mailbox *m)
     {
       /* mx_mbox_close won't sync if there are no deleted messages
        * and the mailbox is unchanged, so we may have to close here */
-      if (!m->msg_deleted)
+      if (m->msg_deleted == 0)
       {
         adata->closing = true;
         imap_exec(adata, "CLOSE", IMAP_CMD_QUEUE);
diff --git a/index.c b/index.c
index b9e1a0907e1543ef643b5701bc6674330c1b8452..77ec40a629983321ac5535b6f208f45ad793e4c3 100644 (file)
--- a/index.c
+++ b/index.c
@@ -129,7 +129,7 @@ static const char *NoVisible = N_("No visible messages");
     mutt_error(_(No_mailbox_is_open));                                         \
     break;                                                                     \
   }                                                                            \
-  else if (!Context->mailbox->msg_count)                                       \
+  else if (Context->mailbox->msg_count == 0)                                   \
   {                                                                            \
     mutt_flushinp();                                                           \
     mutt_error(_(There_are_no_messages));                                      \
@@ -277,7 +277,7 @@ static int ci_previous_undeleted(int msgno)
  */
 static int ci_first_message(void)
 {
-  if (!Context || !Context->mailbox->msg_count)
+  if (!Context || (Context->mailbox->msg_count == 0))
     return 0;
 
   int old = -1;
@@ -635,14 +635,13 @@ static int main_change_folder(struct Menu *menu, int op, struct Mailbox *m,
    * switch statement would need to be run. */
   mutt_folder_hook(buf, m ? m->desc : NULL);
 
-  const int flags =
-    (ReadOnly || (op == OP_MAIN_CHANGE_FOLDER_READONLY)
+  const int flags = (ReadOnly || (op == OP_MAIN_CHANGE_FOLDER_READONLY)
 #ifdef USE_NOTMUCH
-     || (op == OP_MAIN_VFOLDER_FROM_QUERY_READONLY)
+                     || (op == OP_MAIN_VFOLDER_FROM_QUERY_READONLY)
 #endif
-     )
-    ? MUTT_READONLY
-    : 0;
+                         ) ?
+                        MUTT_READONLY :
+                        0;
 
   bool free_m = false;
   if (!m)
@@ -1239,7 +1238,7 @@ int mutt_index_menu(void)
           continue;
         }
 
-        if (!Context->mailbox->msg_tagged)
+        if (Context->mailbox->msg_tagged == 0)
         {
           if (op == OP_TAG_PREFIX)
             mutt_error(_("No tagged messages"));
@@ -1255,7 +1254,7 @@ int mutt_index_menu(void)
         tag = true;
         continue;
       }
-      else if (AutoTag && Context && Context->mailbox && Context->mailbox->msg_tagged)
+      else if (AutoTag && Context && Context->mailbox && (Context->mailbox->msg_tagged != 0))
         tag = true;
 
       mutt_clear_error();
@@ -1665,7 +1664,7 @@ int mutt_index_menu(void)
           }
           else
             menu->current = 0;
-          if (Context->mailbox->msg_count && (Sort & SORT_MASK) == SORT_THREADS)
+          if ((Context->mailbox->msg_count != 0) && (Sort & SORT_MASK) == SORT_THREADS)
             mutt_draw_tree(Context);
           menu->redraw = REDRAW_FULL;
         }
@@ -1728,7 +1727,7 @@ int mutt_index_menu(void)
 
         if (mutt_select_sort((op == OP_SORT_REVERSE)) == 0)
         {
-          if (Context && Context->mailbox->msg_count)
+          if (Context && (Context->mailbox->msg_count != 0))
           {
             resort_index(menu);
             OptSearchInvalid = true;
@@ -1854,7 +1853,7 @@ int mutt_index_menu(void)
 
       case OP_MAIN_SYNC_FOLDER:
 
-        if (Context && !Context->mailbox->msg_count)
+        if (Context && (Context->mailbox->msg_count == 0))
           break;
 
         CHECK_MSGCOUNT;
diff --git a/mx.c b/mx.c
index 06fb7c8a1ba56a3f2dbd97861584f85427b27aec..d5cc8316ba3bada7bb6b7d20f246b6e835a09e37 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -449,7 +449,7 @@ static int trash_append(struct Mailbox *m)
   struct stat st, stc;
   int opt_confappend, rc;
 
-  if (!Trash || !m->msg_deleted || (m->magic == MUTT_MAILDIR && MaildirTrash))
+  if (!Trash || (m->msg_deleted == 0) || (m->magic == MUTT_MAILDIR && MaildirTrash))
   {
     return 0;
   }
@@ -559,7 +559,7 @@ int mx_mbox_close(struct Context **ptr)
   }
 
 #ifdef USE_NNTP
-  if (m->msg_unread && m->magic == MUTT_NNTP)
+  if ((m->msg_unread != 0) && (m->magic == MUTT_NNTP))
   {
     struct NntpMboxData *mdata = m->mdata;
 
@@ -622,7 +622,7 @@ int mx_mbox_close(struct Context **ptr)
   /* There is no point in asking whether or not to purge if we are
    * just marking messages as "trash".
    */
-  if (m->msg_deleted && !(m->magic == MUTT_MAILDIR && MaildirTrash))
+  if ((m->msg_deleted != 0) && !(m->magic == MUTT_MAILDIR && MaildirTrash))
   {
     snprintf(buf, sizeof(buf),
              ngettext("Purge %d deleted message?", "Purge %d deleted messages?", m->msg_deleted),
@@ -705,7 +705,7 @@ int mx_mbox_close(struct Context **ptr)
       mx_mbox_close(&ctx_read);
     }
   }
-  else if (!m->changed && m->msg_deleted == 0)
+  else if (!m->changed && (m->msg_deleted == 0))
   {
     if (!m->quiet)
       mutt_message(_("Mailbox is unchanged"));
@@ -717,7 +717,7 @@ int mx_mbox_close(struct Context **ptr)
   }
 
   /* copy mails to the trash before expunging */
-  if (purge && m->msg_deleted && (mutt_str_strcmp(m->path, Trash) != 0))
+  if (purge && (m->msg_deleted != 0) && (mutt_str_strcmp(m->path, Trash) != 0))
   {
     if (trash_append(ctx->mailbox) != 0)
       return -1;
@@ -763,7 +763,8 @@ int mx_mbox_close(struct Context **ptr)
       mutt_message(_("%d kept, %d deleted"), m->msg_count - m->msg_deleted, m->msg_deleted);
   }
 
-  if (m->msg_count == m->msg_deleted && (m->magic == MUTT_MMDF || m->magic == MUTT_MBOX) &&
+  if ((m->msg_count == m->msg_deleted) &&
+      ((m->magic == MUTT_MMDF) || (m->magic == MUTT_MBOX)) &&
       !mutt_is_spool(m->path) && !SaveEmpty)
   {
     mutt_file_unlink_empty(m->path);
@@ -825,7 +826,7 @@ int mx_mbox_sync(struct Mailbox *m, int *index_hint)
     return -1;
   }
 
-  if (!m->changed && !m->msg_deleted)
+  if (!m->changed && (m->msg_deleted == 0))
   {
     if (!m->quiet)
       mutt_message(_("Mailbox is unchanged"));
@@ -865,7 +866,7 @@ int mx_mbox_sync(struct Mailbox *m, int *index_hint)
   msgcount = m->msg_count;
   deleted = m->msg_deleted;
 
-  if (purge && m->msg_deleted && (mutt_str_strcmp(m->path, Trash) != 0))
+  if (purge && (m->msg_deleted != 0) && (mutt_str_strcmp(m->path, Trash) != 0))
   {
     if (trash_append(m) != 0)
       return -1;
@@ -894,7 +895,8 @@ int mx_mbox_sync(struct Mailbox *m, int *index_hint)
 
     mutt_sleep(0);
 
-    if (m->msg_count == m->msg_deleted && (m->magic == MUTT_MBOX || m->magic == MUTT_MMDF) &&
+    if ((m->msg_count == m->msg_deleted) &&
+        ((m->magic == MUTT_MBOX) || (m->magic == MUTT_MMDF)) &&
         !mutt_is_spool(m->path) && !SaveEmpty)
     {
       unlink(m->path);
index 6640c3e63b09a15b1181379c54ba604fa1169c36..7693a631e87a90efaee6cd62fbc63944387ba57c 100644 (file)
@@ -312,7 +312,7 @@ int mutt_get_postponed(struct Context *ctx, struct Email *hdr,
     return -1;
   }
 
-  if (!ctx_post->mailbox->msg_count)
+  if (ctx_post->mailbox->msg_count == 0)
   {
     PostCount = 0;
     if (ctx_post == ctx)
diff --git a/send.c b/send.c
index a4f9a1bcb22aa9830ced36339bb9709294507cd7..1b048e9f5c30e13d4ee940adef2e3d3dab97ab75 100644 (file)
--- a/send.c
+++ b/send.c
@@ -2475,7 +2475,8 @@ int ci_send_message(int flags, struct Email *msg, const char *tempfile,
   {
     if (cur && ctx)
       mutt_set_flag(ctx->mailbox, cur, MUTT_REPLIED, is_reply(cur, msg));
-    else if (!(flags & SEND_POSTPONED) && ctx && ctx->mailbox && ctx->mailbox->msg_tagged)
+    else if (!(flags & SEND_POSTPONED) && ctx && ctx->mailbox &&
+             (ctx->mailbox->msg_tagged != 0))
     {
       STAILQ_FOREACH(en, el, entries)
       {
index cf60d04f3d478c79b163d9b1b6ea728515d7c40b..fcc98aee46f7fa02234f71ea2f45559eae7649ab 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -144,7 +144,7 @@ static const char *sidebar_format_str(char *buf, size_t buflen, size_t col, int
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, c ? Context->mailbox->msg_deleted : 0);
       }
-      else if ((c && Context->mailbox->msg_deleted == 0) || !c)
+      else if ((c && (Context->mailbox->msg_deleted == 0)) || !c)
         optional = 0;
       break;
 
@@ -211,7 +211,7 @@ static const char *sidebar_format_str(char *buf, size_t buflen, size_t col, int
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, c ? Context->mailbox->msg_tagged : 0);
       }
-      else if ((c && Context->mailbox->msg_tagged == 0) || !c)
+      else if ((c && (Context->mailbox->msg_tagged == 0)) || !c)
         optional = 0;
       break;
 
@@ -486,7 +486,7 @@ static int select_next_new(void)
     }
     if (entry == HilIndex)
       return false;
-  } while (!Entries[entry]->mailbox->has_new && !Entries[entry]->mailbox->msg_unread);
+  } while (!Entries[entry]->mailbox->has_new && (Entries[entry]->mailbox->msg_unread == 0));
 
   HilIndex = entry;
   return true;
@@ -541,7 +541,7 @@ static bool select_prev_new(void)
     }
     if (entry == HilIndex)
       return false;
-  } while (!Entries[entry]->mailbox->has_new && !Entries[entry]->mailbox->msg_unread);
+  } while (!Entries[entry]->mailbox->has_new && (Entries[entry]->mailbox->msg_unread == 0));
 
   HilIndex = entry;
   return true;
diff --git a/sort.c b/sort.c
index bf5532dd80089bb6b6a220f4bdad171f4a300e69..3ab9e2092a2c68f04e6d300166974f7f0c299d4e 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -368,7 +368,7 @@ void mutt_sort_headers(struct Context *ctx, bool init)
   if (!ctx)
     return;
 
-  if (!ctx->mailbox->msg_count)
+  if (ctx->mailbox->msg_count == 0)
   {
     /* this function gets called by mutt_sync_mailbox(), which may have just
      * deleted all the messages.  the virtual message numbers are not updated
index f719a49401a45bac0362980ccab2b77f89f1be91..cc113be1c0d78c3dbd984a4d7ee3cf8ab514392c 100644 (file)
--- a/status.c
+++ b/status.c
@@ -115,7 +115,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_deleted : 0);
       }
-      else if (!Context || !Context->mailbox->msg_deleted)
+      else if (!Context || (Context->mailbox->msg_deleted == 0))
         optional = 0;
       break;
 
@@ -166,7 +166,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_flagged : 0);
       }
-      else if (!Context || !Context->mailbox->msg_flagged)
+      else if (!Context || (Context->mailbox->msg_flagged == 0))
         optional = 0;
       break;
 
@@ -203,7 +203,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_count : 0);
       }
-      else if (!Context || !Context->mailbox->msg_count)
+      else if (!Context || (Context->mailbox->msg_count == 0))
         optional = 0;
       break;
 
@@ -223,7 +223,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_new : 0);
       }
-      else if (!Context || !Context->mailbox->msg_new)
+      else if (!Context || (Context->mailbox->msg_new == 0))
         optional = 0;
       break;
 
@@ -232,9 +232,9 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
       {
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt,
-                 Context ? Context->mailbox->msg_unread - Context->mailbox->msg_new : 0);
+                 Context ? (Context->mailbox->msg_unread - Context->mailbox->msg_new) : 0);
       }
-      else if (!Context || !(Context->mailbox->msg_unread - Context->mailbox->msg_new))
+      else if (!Context || ((Context->mailbox->msg_unread - Context->mailbox->msg_new) == 0))
         optional = 0;
       break;
 
@@ -298,7 +298,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
 
     case 'R':
     {
-      int read = Context ? Context->mailbox->msg_count - Context->mailbox->msg_unread : 0;
+      int read = Context ? (Context->mailbox->msg_count - Context->mailbox->msg_unread) : 0;
 
       if (!optional)
       {
@@ -326,7 +326,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_tagged : 0);
       }
-      else if (!Context || !Context->mailbox || !Context->mailbox->msg_tagged)
+      else if (!Context || !Context->mailbox || (Context->mailbox->msg_tagged == 0))
         optional = 0;
       break;
 
@@ -336,7 +336,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
         snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_unread : 0);
       }
-      else if (!Context || !Context->mailbox->msg_unread)
+      else if (!Context || (Context->mailbox->msg_unread == 0))
         optional = 0;
       break;