From: Richard Russon Date: Thu, 17 Jan 2019 19:58:57 +0000 (+0000) Subject: compare integers against 0 X-Git-Tag: 2019-10-25~372^2~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5076eed3fa7f0c0953a490e43f4d2cb42483bafe;p=neomutt compare integers against 0 --- diff --git a/compose.c b/compose.c index 70b832373..b4fcef89d 100644 --- 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")); diff --git a/imap/imap.c b/imap/imap.c index b752b9795..4d32c0499 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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 b9e1a0907..77ec40a62 100644 --- 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 06fb7c8a1..d5cc8316b 100644 --- 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); diff --git a/postpone.c b/postpone.c index 6640c3e63..7693a631e 100644 --- a/postpone.c +++ b/postpone.c @@ -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 a4f9a1bcb..1b048e9f5 100644 --- 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) { diff --git a/sidebar.c b/sidebar.c index cf60d04f3..fcc98aee4 100644 --- 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 bf5532dd8..3ab9e2092 100644 --- 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 diff --git a/status.c b/status.c index f719a4940..cc113be1c 100644 --- 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;