From: Richard Russon Date: Fri, 17 Aug 2018 01:20:19 +0000 (+0100) Subject: kill unnecessary == NULL X-Git-Tag: 2019-10-25~687^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0109c67393b764b5d6565e42112ac28ce2cb9d04;p=neomutt kill unnecessary == NULL --- diff --git a/alias.c b/alias.c index 077a0c09d..1ab40fb1d 100644 --- a/alias.c +++ b/alias.c @@ -213,7 +213,7 @@ static int check_alias_name(const char *s, char *dest, size_t destlen) int bad = l == (size_t)(-1) || l == (size_t)(-2); /* conversion error */ bad = bad || (!dry && l > destlen); /* too few room for mb char */ if (l == 1) - bad = bad || (strchr("-_+=.", *s) == NULL && !iswalnum(wc)); + bad = bad || (!strchr("-_+=.", *s) && !iswalnum(wc)); else bad = bad || !iswalnum(wc); if (bad) diff --git a/complete.c b/complete.c index 67d242dd0..76f60db69 100644 --- a/complete.c +++ b/complete.c @@ -158,8 +158,8 @@ int mutt_complete(char *buf, size_t buflen) if (p) { char tmp[PATH_MAX]; - if (mutt_path_concatn(tmp, sizeof(tmp), exp_dirpart, strlen(exp_dirpart), - buf + 1, (size_t)(p - buf - 1)) == NULL) + if (!mutt_path_concatn(tmp, sizeof(tmp), exp_dirpart, strlen(exp_dirpart), + buf + 1, (size_t)(p - buf - 1))) { return -1; } diff --git a/compose.c b/compose.c index ab32cc73f..8b7082378 100644 --- a/compose.c +++ b/compose.c @@ -1200,7 +1200,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, /* append bptr to the alts list, * and remove from the msg->content list */ - if (alts == NULL) + if (!alts) { group->parts = alts = bptr; bptr = bptr->next; @@ -1298,7 +1298,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, /* append bptr to the alts list, * and remove from the msg->content list */ - if (alts == NULL) + if (!alts) { group->parts = alts = bptr; bptr = bptr->next; diff --git a/copy.c b/copy.c index 18c22195e..a1d086b20 100644 --- a/copy.c +++ b/copy.c @@ -102,7 +102,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, { nl = strchr(buf, '\n'); - if ((fgets(buf, sizeof(buf), in)) == NULL) + if (!fgets(buf, sizeof(buf), in)) break; /* Is it the beginning of a header? */ @@ -177,7 +177,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, nl = strchr(buf, '\n'); /* Read a line */ - if ((fgets(buf, sizeof(buf), in)) == NULL) + if (!fgets(buf, sizeof(buf), in)) break; /* Is it the beginning of a header? */ @@ -820,7 +820,7 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src, if (fseeko(fpin, hdr->offset, SEEK_SET) < 0) return -1; - if (fgets(buf, sizeof(buf), fpin) == NULL) + if (!fgets(buf, sizeof(buf), fpin)) return -1; msg = mx_msg_open_new(dest, hdr, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM); diff --git a/curs_main.c b/curs_main.c index dd6de7407..cd3024ee5 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1330,7 +1330,7 @@ int mutt_index_menu(void) struct ListNode *ref = NULL; STAILQ_FOREACH(ref, &CURHDR->env->references, entries) { - if (mutt_hash_find(Context->id_hash, ref->data) == NULL) + if (!mutt_hash_find(Context->id_hash, ref->data)) { rc2 = nntp_check_msgid(Context, ref->data); if (rc2 < 0) diff --git a/edit.c b/edit.c index dda2d5b4c..d1f775760 100644 --- a/edit.c +++ b/edit.c @@ -101,7 +101,7 @@ static char **be_snarf_data(FILE *f, char **buf, int *bufmax, int *buflen, fseeko(f, offset, SEEK_SET); while (bytes > 0) { - if (fgets(p, tmplen - 1, f) == NULL) + if (!fgets(p, tmplen - 1, f)) break; bytes -= mutt_str_strlen(p); if (*bufmax == *buflen) diff --git a/editmsg.c b/editmsg.c index 0263035f5..bbd404cc5 100644 --- a/editmsg.c +++ b/editmsg.c @@ -83,7 +83,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade omagic = MboxType; MboxType = MUTT_MBOX; - rc = (mx_mbox_open(tmp, MUTT_NEWFOLDER, &tmpctx) == NULL) ? -1 : 0; + rc = mx_mbox_open(tmp, MUTT_NEWFOLDER, &tmpctx) ? 0 : -1; MboxType = omagic; @@ -185,7 +185,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade goto bail; } - if (mx_mbox_open(ctx->path, MUTT_APPEND, &tmpctx) == NULL) + if (!mx_mbox_open(ctx->path, MUTT_APPEND, &tmpctx)) { rc = -1; /* L10N: %s is from strerror(errno) */ diff --git a/email/parameter.c b/email/parameter.c index e38bda6cf..8f3bad466 100644 --- a/email/parameter.c +++ b/email/parameter.c @@ -162,14 +162,10 @@ void mutt_param_delete(struct ParameterList *p, const char *attribute) bool mutt_param_cmp_strict(const struct ParameterList *p1, const struct ParameterList *p2) { if (!p1 && !p2) - { return false; - } if ((p1 == NULL) ^ (p2 == NULL)) - { return true; - } struct Parameter *np1 = TAILQ_FIRST(p1); struct Parameter *np2 = TAILQ_FIRST(p2); diff --git a/email/parse.c b/email/parse.c index 890821971..74392abd2 100644 --- a/email/parse.c +++ b/email/parse.c @@ -154,7 +154,7 @@ static void parse_parameters(struct ParameterList *param, const char *s) } /* Find the next parameter */ - if ((*s != ';') && (s = strchr(s, ';')) == NULL) + if ((*s != ';') && !(s = strchr(s, ';'))) break; /* no more parameters */ do diff --git a/email/rfc2047.c b/email/rfc2047.c index 162b87858..43b21b83a 100644 --- a/email/rfc2047.c +++ b/email/rfc2047.c @@ -142,7 +142,7 @@ static char *parse_encoded_word(char *str, enum ContentEncoding *enc, char **cha regmatch_t match[4]; size_t nmatch = 4; - if (re == NULL) + if (!re) { re = mutt_regex_compile("=\\?" "([^][()<>@,;:\\\"/?. =]+)" /* charset */ diff --git a/handler.c b/handler.c index bf70ec1af..0d91566a4 100644 --- a/handler.c +++ b/handler.c @@ -314,7 +314,7 @@ static void decode_quoted(struct State *s, long len, bool istext, iconv_t cd) * lines are at most 76 characters, but we should be liberal about what * we accept. */ - if (fgets(line, MIN((ssize_t) sizeof(line), len + 1), s->fpin) == NULL) + if (!fgets(line, MIN((ssize_t) sizeof(line), len + 1), s->fpin)) break; size_t linelen = strlen(line); @@ -374,7 +374,7 @@ static void decode_uuencoded(struct State *s, long len, bool istext, iconv_t cd) while (len > 0) { - if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL) + if (!fgets(tmps, sizeof(tmps), s->fpin)) return; len -= mutt_str_strlen(tmps); if ((mutt_str_strncmp(tmps, "begin", 5) == 0) && ISSPACE(tmps[5])) @@ -382,7 +382,7 @@ static void decode_uuencoded(struct State *s, long len, bool istext, iconv_t cd) } while (len > 0) { - if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL) + if (!fgets(tmps, sizeof(tmps), s->fpin)) return; len -= mutt_str_strlen(tmps); if (mutt_str_strncmp(tmps, "end", 3) == 0) diff --git a/hdrline.c b/hdrline.c index a6e5f7292..35e982edb 100644 --- a/hdrline.c +++ b/hdrline.c @@ -429,7 +429,7 @@ static char *apply_subject_mods(struct Envelope *env) if (STAILQ_EMPTY(&SubjectRegexList)) return env->subject; - if (env->subject == NULL || *env->subject == '\0') + if (!env->subject || *env->subject == '\0') { env->disp_subj = NULL; return NULL; diff --git a/imap/util.c b/imap/util.c index d3d7ba653..3ae743fb5 100644 --- a/imap/util.c +++ b/imap/util.c @@ -1019,8 +1019,8 @@ int imap_account_match(const struct Account *a1, const struct Account *a2) { struct ImapData *a1_idata = imap_conn_find(a1, MUTT_IMAP_CONN_NONEW); struct ImapData *a2_idata = imap_conn_find(a2, MUTT_IMAP_CONN_NONEW); - const struct Account *a1_canon = a1_idata == NULL ? a1 : &a1_idata->conn->account; - const struct Account *a2_canon = a2_idata == NULL ? a2 : &a2_idata->conn->account; + const struct Account *a1_canon = a1_idata ? &a1_idata->conn->account : a1; + const struct Account *a2_canon = a2_idata ? &a2_idata->conn->account : a2; return mutt_account_match(a1_canon, a2_canon); } diff --git a/maildir/mh.c b/maildir/mh.c index f94bd5723..3042b0dcf 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -1672,7 +1672,7 @@ static int maildir_mh_open_message(struct Context *ctx, struct Message *msg, snprintf(path, sizeof(path), "%s/%s", ctx->path, cur->path); msg->fp = fopen(path, "r"); - if (msg->fp == NULL && errno == ENOENT && is_maildir) + if (!msg->fp && (errno == ENOENT) && is_maildir) msg->fp = maildir_open_find_message(ctx->path, cur->path, NULL); if (!msg->fp) diff --git a/mbox/mbox.c b/mbox/mbox.c index 23e23f1a6..ba0a070b1 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -144,7 +144,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) while (true) { - if (fgets(buf, sizeof(buf) - 1, ctx->fp) == NULL) + if (!fgets(buf, sizeof(buf) - 1, ctx->fp)) break; if (SigInt == 1) @@ -166,7 +166,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) hdr->offset = loc; hdr->index = ctx->msgcount; - if (fgets(buf, sizeof(buf) - 1, ctx->fp) == NULL) + if (!fgets(buf, sizeof(buf) - 1, ctx->fp)) { /* TODO: memory leak??? */ mutt_debug(1, "unexpected EOF\n"); @@ -200,7 +200,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) if ((tmploc > 0) && (tmploc < ctx->size)) { if (fseeko(ctx->fp, tmploc, SEEK_SET) != 0 || - fgets(buf, sizeof(buf) - 1, ctx->fp) == NULL || + !fgets(buf, sizeof(buf) - 1, ctx->fp) || (mutt_str_strcmp(MMDF_SEP, buf) != 0)) { if (fseeko(ctx->fp, loc, SEEK_SET) != 0) @@ -222,7 +222,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) loc = ftello(ctx->fp); if (loc < 0) return -1; - if (fgets(buf, sizeof(buf) - 1, ctx->fp) == NULL) + if (!fgets(buf, sizeof(buf) - 1, ctx->fp)) break; lines++; } while (mutt_str_strcmp(buf, MMDF_SEP) != 0); @@ -363,7 +363,7 @@ static int mbox_parse_mailbox(struct Context *ctx) * to see a valid message separator at this point in the stream */ if (fseeko(ctx->fp, tmploc, SEEK_SET) != 0 || - fgets(buf, sizeof(buf), ctx->fp) == NULL || + !fgets(buf, sizeof(buf), ctx->fp) || (mutt_str_strncmp("From ", buf, 5) != 0)) { mutt_debug(1, "bad content-length in message %d (cl=" OFF_T_FMT ")\n", @@ -1018,7 +1018,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) /* Create a temporary file to write the new version of the mailbox in. */ mutt_mktemp(tempfile, sizeof(tempfile)); i = open(tempfile, O_WRONLY | O_EXCL | O_CREAT, 0600); - if ((i == -1) || (fp = fdopen(i, "w")) == NULL) + if ((i == -1) || !(fp = fdopen(i, "w"))) { if (-1 != i) { @@ -1175,7 +1175,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) if (fseeko(ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */ /* do a sanity check to make sure the mailbox looks ok */ - fgets(buf, sizeof(buf), ctx->fp) == NULL || + !fgets(buf, sizeof(buf), ctx->fp) || (ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buf, 5) != 0)) || (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buf) != 0))) { diff --git a/mutt/file.c b/mutt/file.c index fead75ee0..6abf78437 100644 --- a/mutt/file.c +++ b/mutt/file.c @@ -304,7 +304,7 @@ int mutt_file_symlink(const char *oldpath, const char *newpath) { char abs_oldpath[PATH_MAX]; - if ((getcwd(abs_oldpath, sizeof(abs_oldpath)) == NULL) || + if (!getcwd(abs_oldpath, sizeof(abs_oldpath)) || ((strlen(abs_oldpath) + 1 + strlen(oldpath) + 1) > sizeof(abs_oldpath))) { return -1; @@ -612,7 +612,7 @@ char *mutt_file_read_line(char *s, size_t *size, FILE *fp, int *line, int flags) while (true) { - if (fgets(s + offset, *size - offset, fp) == NULL) + if (!fgets(s + offset, *size - offset, fp)) { FREE(&s); return NULL; diff --git a/mutt/history.c b/mutt/history.c index e29e9f1c3..c5b4aa0d2 100644 --- a/mutt/history.c +++ b/mutt/history.c @@ -527,7 +527,7 @@ char *mutt_hist_next(enum HistoryClass hclass) next = 0; if (next == h->last) break; - } while (h->hist[next] == NULL); + } while (!h->hist[next]); h->cur = next; return NONULL(h->hist[h->cur]); @@ -555,7 +555,7 @@ char *mutt_hist_prev(enum HistoryClass hclass) prev = History; if (prev == h->last) break; - } while (h->hist[prev] == NULL); + } while (!h->hist[prev]); h->cur = prev; return NONULL(h->hist[h->cur]); diff --git a/mutt/path.c b/mutt/path.c index 66d7ab2f2..52850ceef 100644 --- a/mutt/path.c +++ b/mutt/path.c @@ -427,7 +427,7 @@ size_t mutt_path_realpath(char *buf) { char s[PATH_MAX]; - if (realpath(buf, s) == NULL) + if (!realpath(buf, s)) return 0; return mutt_str_strfcpy(buf, s, sizeof(s)); diff --git a/mutt/regex.c b/mutt/regex.c index a720855da..6c9c37089 100644 --- a/mutt/regex.c +++ b/mutt/regex.c @@ -358,7 +358,7 @@ char *mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, c if (buf && buflen) buf[0] = '\0'; - if (str == NULL || *str == '\0' || (buf && !buflen)) + if (!str || *str == '\0' || (buf && !buflen)) return buf; twinbuf[0][0] = '\0'; diff --git a/mutt_attach.c b/mutt_attach.c index e71e3b4b0..e6945aebe 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -436,7 +436,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr, if (rfc1524_expand_filename(entry->nametemplate, fname, tempfile, sizeof(tempfile))) { - if (fp == NULL && (mutt_str_strcmp(tempfile, a->filename) != 0)) + if (!fp && (mutt_str_strcmp(tempfile, a->filename) != 0)) { /* send case: the file is already there */ if (mutt_file_symlink(a->filename, tempfile) == -1) @@ -802,9 +802,9 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct if (fseeko(fp, m->offset, SEEK_SET) < 0) return -1; - if (fgets(buf, sizeof(buf), fp) == NULL) + if (!fgets(buf, sizeof(buf), fp)) return -1; - if (mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET, &ctx) == NULL) + if (!mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET, &ctx)) return -1; msg = mx_msg_open_new(&ctx, hn, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM); if (!msg) diff --git a/mutt_lua.c b/mutt_lua.c index f2a93de21..f4a86b126 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -117,7 +117,7 @@ static int lua_mutt_call(lua_State *l) } else { - if (lua_pushstring(l, err.data) == NULL) + if (!lua_pushstring(l, err.data)) handle_error(l); else rc++; @@ -303,7 +303,7 @@ static int lua_mutt_enter(lua_State *l) } else { - if (lua_pushstring(l, err.data) == NULL) + if (!lua_pushstring(l, err.data)) handle_error(l); else rc++; diff --git a/mutt_thread.c b/mutt_thread.c index 025c32cea..16551e948 100644 --- a/mutt_thread.c +++ b/mutt_thread.c @@ -1228,7 +1228,7 @@ int mutt_traverse_thread(struct Context *ctx, struct Header *cur, int flag) } } - if (thread == top && (thread = thread->child) == NULL) + if ((thread == top) && !(thread = thread->child)) { /* return value depends on action requested */ if (flag & (MUTT_THREAD_COLLAPSE | MUTT_THREAD_UNCOLLAPSE)) diff --git a/mx.c b/mx.c index cafc57c87..2c88b0407 100644 --- a/mx.c +++ b/mx.c @@ -835,7 +835,7 @@ int mx_mbox_close(struct Context *ctx, int *index_hint) else /* use regular append-copy mode */ #endif { - if (mx_mbox_open(mbox, MUTT_APPEND, &f) == NULL) + if (!mx_mbox_open(mbox, MUTT_APPEND, &f)) { ctx->closing = false; return -1; diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index bb8668086..92367c8b2 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -1299,7 +1299,7 @@ bool crypt_is_numerical_keyid(const char *s) if (strlen(s) % 8) return false; while (*s) - if (strchr("0123456789ABCDEFabcdef", *s++) == NULL) + if (!strchr("0123456789ABCDEFabcdef", *s++)) return false; return true; diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 57ec06912..0e597be84 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -2563,7 +2563,7 @@ int pgp_gpgme_application_handler(struct Body *m, struct State *s) for (bytes = m->length; bytes > 0;) { - if (fgets(buf, sizeof(buf), s->fpin) == NULL) + if (!fgets(buf, sizeof(buf), s->fpin)) break; LOFF_T offset = ftello(s->fpin); diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 70f3900ce..3d06da3d3 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -490,7 +490,7 @@ int pgp_class_application_handler(struct Body *m, struct State *s) for (bytes = m->length; bytes > 0;) { - if (fgets(buf, sizeof(buf), s->fpin) == NULL) + if (!fgets(buf, sizeof(buf), s->fpin)) break; offset = ftello(s->fpin); diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 6b9e5fac0..9f39dfe0d 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -642,7 +642,7 @@ static int active_get_cache(struct NntpServer *nserv) if (!fp) return -1; - if (fgets(buf, sizeof(buf), fp) == NULL || sscanf(buf, "%ld%s", &t, file) != 1 || t == 0) + if (!fgets(buf, sizeof(buf), fp) || (sscanf(buf, "%ld%s", &t, file) != 1) || (t == 0)) { mutt_file_fclose(&fp); return -1; diff --git a/nntp/nntp.c b/nntp/nntp.c index 81e55acba..2cc95be62 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -1164,7 +1164,7 @@ static int parse_overview_line(char *line, void *data) if (*header) { - if (strstr(header, ":full") == NULL && fputs(header, fp) == EOF) + if (!strstr(header, ":full") && (fputs(header, fp) == EOF)) { mutt_file_fclose(&fp); return -1; @@ -1296,7 +1296,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, fc.last = last; fc.restore = restore; fc.messages = mutt_mem_calloc(last - first + 1, sizeof(unsigned char)); - if (fc.messages == NULL) + if (!fc.messages) return -1; #ifdef USE_HCACHE fc.hc = hc; @@ -2214,7 +2214,7 @@ static int nntp_mbox_close(struct Context *ctx) return 0; nntp_tmp = mutt_hash_find(nntp_data->nserv->groups_hash, nntp_data->group); - if (nntp_tmp == NULL || nntp_tmp != nntp_data) + if (!nntp_tmp || nntp_tmp != nntp_data) nntp_data_free(nntp_data); return 0; } diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index addc6299b..50754f933 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -408,7 +408,7 @@ static bool windowed_query_from_query(const char *query, char *buf, size_t bufle } /* if the query has changed, reset the window position */ - if (NmQueryWindowCurrentSearch == NULL || (strcmp(query, NmQueryWindowCurrentSearch) != 0)) + if (!NmQueryWindowCurrentSearch || (strcmp(query, NmQueryWindowCurrentSearch) != 0)) query_window_reset(); if (!query_window_check_timebase(NmQueryWindowTimebase)) @@ -1974,14 +1974,14 @@ bool nm_normalize_uri(char *new_uri, const char *orig_uri, size_t new_uri_sz) mutt_debug(2, "#1 () -> db_query: %s\n", tmp_ctxdata->db_query); - if (get_query_string(tmp_ctxdata, false) == NULL) + if (!get_query_string(tmp_ctxdata, false)) goto gone; mutt_debug(2, "#2 () -> db_query: %s\n", tmp_ctxdata->db_query); mutt_str_strfcpy(buf, tmp_ctxdata->db_query, sizeof(buf)); - if (nm_uri_from_query(&tmp_ctx, buf, sizeof(buf)) == NULL) + if (!nm_uri_from_query(&tmp_ctx, buf, sizeof(buf))) goto gone; strncpy(new_uri, buf, new_uri_sz); diff --git a/pager.c b/pager.c index ce05d5361..4f3b6e75c 100644 --- a/pager.c +++ b/pager.c @@ -622,7 +622,7 @@ static struct QClass *classify_quote(struct QClass **quote_list, const char *qpt /* case 2: try subclassing the current top level node */ /* tmp != NULL means we already found a shorter prefix at case 1 */ - if (tmp == NULL && (mutt_str_strncmp(qptr, q_list->prefix, q_list->length) == 0)) + if (!tmp && (mutt_str_strncmp(qptr, q_list->prefix, q_list->length) == 0)) { /* ok, it's a subclass somewhere on this branch */ @@ -724,7 +724,7 @@ static struct QClass *classify_quote(struct QClass **quote_list, const char *qpt else { /* longer than the current prefix: try subclassing it */ - if (tmp == NULL && (mutt_str_strncmp(tail_qptr, (q_list->prefix) + offset, + if (!tmp && (mutt_str_strncmp(tail_qptr, (q_list->prefix) + offset, q_list->length - offset) == 0)) { /* still a subclass: go down one level */ @@ -944,7 +944,7 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n, if (regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0) { - if (q_classify && line_info[n].quote == NULL) + if (q_classify && !line_info[n].quote) { line_info[n].quote = classify_quote(quote_list, buf + pmatch[0].rm_so, pmatch[0].rm_eo - pmatch[0].rm_so, @@ -962,7 +962,7 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n, } else { - if (q_classify && line_info[n].quote == NULL) + if (q_classify && !line_info[n].quote) { line_info[n].quote = classify_quote(quote_list, buf + pmatch[0].rm_so, pmatch[0].rm_eo - pmatch[0].rm_so, @@ -1638,7 +1638,7 @@ static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info, int * length of the quote prefix. */ if ((flags & MUTT_SHOWCOLOR) && !(*line_info)[n].continuation && - (*line_info)[n].type == MT_COLOR_QUOTED && (*line_info)[n].quote == NULL) + ((*line_info)[n].type == MT_COLOR_QUOTED) && !(*line_info)[n].quote) { if (fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0) { diff --git a/pattern.c b/pattern.c index a7a47ffa8..2c039bd19 100644 --- a/pattern.c +++ b/pattern.c @@ -1084,7 +1084,7 @@ static bool msg_search(struct Context *ctx, struct Pattern *pat, int msgno) if (*buf == '\0') break; } - else if (fgets(buf, blen - 1, fp) == NULL) + else if (!fgets(buf, blen - 1, fp)) break; /* don't loop forever */ if (patmatch(pat, buf) == 0) { diff --git a/pop/pop.c b/pop/pop.c index a6d32e109..8e969d7a4 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -968,7 +968,7 @@ void pop_fetch_mail(void) goto finish; } - if (mx_mbox_open(Spoolfile, MUTT_APPEND, &ctx) == NULL) + if (!mx_mbox_open(Spoolfile, MUTT_APPEND, &ctx)) goto finish; delanswer = query_quadoption(PopDelete, _("Delete messages from server?")); diff --git a/postpone.c b/postpone.c index 94c7118dc..b05051da5 100644 --- a/postpone.c +++ b/postpone.c @@ -162,7 +162,7 @@ int mutt_num_postponed(bool force) if (optnews) OptNews = false; #endif - if (mx_mbox_open(Postponed, MUTT_NOSORT | MUTT_QUIET, &ctx) == NULL) + if (!mx_mbox_open(Postponed, MUTT_NOSORT | MUTT_QUIET, &ctx)) PostCount = 0; else PostCount = ctx.msgcount; @@ -311,7 +311,7 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, /* only one message, so just use that one. */ h = PostContext->hdrs[0]; } - else if ((h = select_msg()) == NULL) + else if (!(h = select_msg())) { mx_mbox_close(PostContext, NULL); FREE(&PostContext); @@ -568,7 +568,7 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, struct State s = { 0 }; int sec_type; - if (!fp && (msg = mx_msg_open(ctx, hdr->msgno)) == NULL) + if (!fp && !(msg = mx_msg_open(ctx, hdr->msgno))) return -1; if (!fp) @@ -605,7 +605,7 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, goto bail; mutt_message(_("Decrypting message...")); - if ((crypt_pgp_decrypt_mime(fp, &bfp, newhdr->content, &b) == -1) || b == NULL) + if ((crypt_pgp_decrypt_mime(fp, &bfp, newhdr->content, &b) == -1) || !b) { goto bail; } diff --git a/recvcmd.c b/recvcmd.c index 47deb92ff..b595e60c5 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -579,7 +579,7 @@ static void attach_forward_bodies(FILE *fp, struct Header *hdr, struct AttachCtx } } - if (mime_fwd_any && copy_problematic_attachments(last, actx, mime_fwd_all) == NULL) + if (mime_fwd_any && !copy_problematic_attachments(last, actx, mime_fwd_all)) goto bail; } @@ -1020,7 +1020,7 @@ void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx, mutt_make_post_indent(Context, parent_hdr, tmpfp); if (mime_reply_any && !cur && - copy_problematic_attachments(&tmphdr->content, actx, false) == NULL) + !copy_problematic_attachments(&tmphdr->content, actx, false)) { mutt_header_free(&tmphdr); mutt_file_fclose(&tmpfp); diff --git a/remailer.c b/remailer.c index 4c9017b31..e5cd659ff 100644 --- a/remailer.c +++ b/remailer.c @@ -782,7 +782,7 @@ int mix_check_message(struct Header *msg) for (struct Address *a = msg->env->to; a; a = a->next) { - if (!a->group && strchr(a->mailbox, '@') == NULL) + if (!a->group && !strchr(a->mailbox, '@')) { need_hostname = true; break; diff --git a/send.c b/send.c index b0ba7cdb9..eea50f3a2 100644 --- a/send.c +++ b/send.c @@ -334,7 +334,7 @@ static int edit_envelope(struct Envelope *en, int flags) else #endif { - if (edit_address(&en->to, _("To: ")) == -1 || en->to == NULL) + if (edit_address(&en->to, _("To: ")) == -1 || !en->to) return -1; if (Askcc && edit_address(&en->cc, _("Cc: ")) == -1) return -1; @@ -1103,7 +1103,7 @@ static int generate_body(FILE *tempfp, struct Header *msg, int flags, { struct Body *b = NULL; - if (((WithCrypto & APPLICATION_PGP) != 0) && (b = crypt_pgp_make_key_attachment()) == NULL) + if (((WithCrypto & APPLICATION_PGP) != 0) && !(b = crypt_pgp_make_key_attachment())) { return -1; } diff --git a/sendlib.c b/sendlib.c index b4b2629eb..bf642b98e 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2971,7 +2971,7 @@ static int bounce_message(FILE *fp, struct Header *h, struct Address *to, } /* If we failed to open a message, return with error */ - if (!fp && (msg = mx_msg_open(Context, h->msgno)) == NULL) + if (!fp && !(msg = mx_msg_open(Context, h->msgno))) return -1; if (!fp) @@ -3175,7 +3175,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid, #ifdef RECORD_FOLDER_HOOK mutt_folder_hook(path); #endif - if (mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET, &f) == NULL) + if (!mx_mbox_open(path, MUTT_APPEND | MUTT_QUIET, &f)) { mutt_debug(1, "unable to open mailbox %s in append-mode, aborting.\n", path); goto done; diff --git a/sort.c b/sort.c index 444ec7477..1797e40f1 100644 --- a/sort.c +++ b/sort.c @@ -408,8 +408,8 @@ void mutt_sort_headers(struct Context *ctx, bool init) } mutt_sort_threads(ctx, init); } - else if ((sortfunc = mutt_get_sort_func(Sort)) == NULL || - (AuxSort = mutt_get_sort_func(SortAux)) == NULL) + else if (!(sortfunc = mutt_get_sort_func(Sort)) || + !(AuxSort = mutt_get_sort_func(SortAux))) { mutt_error(_("Could not find sorting function [report this bug]")); return;