From: Richard Russon Date: Fri, 17 Aug 2018 00:47:53 +0000 (+0100) Subject: kill unnecessary != NULL X-Git-Tag: 2019-10-25~687^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ec437710d0e1924b03ae49a2d5929a9096837b0;p=neomutt kill unnecessary != NULL --- diff --git a/alias.c b/alias.c index 3c02e2a29..077a0c09d 100644 --- a/alias.c +++ b/alias.c @@ -59,7 +59,7 @@ static struct Address *expand_aliases_r(struct Address *a, struct ListHead *expn while (a) { - if (!a->group && !a->personal && a->mailbox && strchr(a->mailbox, '@') == NULL) + if (!a->group && !a->personal && a->mailbox && !strchr(a->mailbox, '@')) { t = mutt_alias_lookup(a->mailbox); diff --git a/bcache.c b/bcache.c index 0527f3666..9eedbe6ac 100644 --- a/bcache.c +++ b/bcache.c @@ -179,7 +179,7 @@ FILE *mutt_bcache_get(struct BodyCache *bcache, const char *id) fp = mutt_file_fopen(path, "r"); - mutt_debug(3, "bcache: get: '%s': %s\n", path, fp == NULL ? "no" : "yes"); + mutt_debug(3, "bcache: get: '%s': %s\n", path, fp ? "yes" : "no"); return fp; } diff --git a/browser.c b/browser.c index 4cb599893..3c0a1ebbc 100644 --- a/browser.c +++ b/browser.c @@ -849,7 +849,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state, init_state(state, menu); - while ((de = readdir(dp)) != NULL) + while ((de = readdir(dp))) { if (mutt_str_strcmp(de->d_name, ".") == 0) continue; /* we don't need . */ diff --git a/commands.c b/commands.c index 9102096ab..09e608440 100644 --- a/commands.c +++ b/commands.c @@ -199,7 +199,7 @@ int mutt_display_message(struct Header *cur) return 0; } - if (fpfilterout != NULL && mutt_wait_filter(filterpid) != 0) + if (fpfilterout && mutt_wait_filter(filterpid) != 0) mutt_any_key_to_continue(NULL); mutt_file_fclose(&fpfilterout); /* XXX - check result? */ @@ -986,7 +986,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) } #endif - if (mx_mbox_open(buf, MUTT_APPEND, &ctx) != NULL) + if (mx_mbox_open(buf, MUTT_APPEND, &ctx)) { #ifdef USE_COMPRESSED /* If we're saving to a compressed mailbox, the stats won't be updated diff --git a/complete.c b/complete.c index e83deb4a4..67d242dd0 100644 --- a/complete.c +++ b/complete.c @@ -214,7 +214,7 @@ int mutt_complete(char *buf, size_t buflen) len = mutt_str_strlen(filepart); if (len == 0) { - while ((de = readdir(dirp)) != NULL) + while ((de = readdir(dirp))) { if ((mutt_str_strcmp(".", de->d_name) != 0) && (mutt_str_strcmp("..", de->d_name) != 0)) @@ -226,7 +226,7 @@ int mutt_complete(char *buf, size_t buflen) } } - while ((de = readdir(dirp)) != NULL) + while ((de = readdir(dirp))) { if (mutt_str_strncmp(de->d_name, filepart, len) == 0) { diff --git a/compose.c b/compose.c index f1b4df5bc..ab32cc73f 100644 --- a/compose.c +++ b/compose.c @@ -1486,7 +1486,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, new = (struct AttachPtr *) mutt_mem_calloc(1, sizeof(struct AttachPtr)); new->content = mutt_make_message_attach(Context, Context->hdrs[i], true); - if (new->content != NULL) + if (new->content) update_idx(menu, actx, new); else { diff --git a/conn/conn_raw.c b/conn/conn_raw.c index 8dada1047..b7a60d8e4 100644 --- a/conn/conn_raw.c +++ b/conn/conn_raw.c @@ -291,7 +291,7 @@ int raw_socket_open(struct Connection *conn) mutt_message(_("Connecting to %s..."), conn->account.host); rc = -1; - for (cur = res; cur != NULL; cur = cur->ai_next) + for (cur = res; cur; cur = cur->ai_next) { int fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol); if (fd >= 0) @@ -350,7 +350,7 @@ int raw_socket_open(struct Connection *conn) mutt_message(_("Connecting to %s..."), conn->account.host); rc = -1; - for (int i = 0; he->h_addr_list[i] != NULL; i++) + for (int i = 0; he->h_addr_list[i]; i++) { memcpy(&sin.sin_addr, he->h_addr_list[i], he->h_length); int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP); diff --git a/conn/getdomain.c b/conn/getdomain.c index 0428b8193..34683180e 100644 --- a/conn/getdomain.c +++ b/conn/getdomain.c @@ -99,7 +99,7 @@ int getdnsdomainname(char *d, size_t len) #endif char *p = NULL; - if (h != NULL && h->ai_canonname && (p = strchr(h->ai_canonname, '.'))) + if (h && h->ai_canonname && (p = strchr(h->ai_canonname, '.'))) { mutt_str_strfcpy(d, ++p, len); rc = 0; diff --git a/conn/ssl.c b/conn/ssl.c index 0276f21bf..a23549cde 100644 --- a/conn/ssl.c +++ b/conn/ssl.c @@ -771,7 +771,7 @@ static bool check_certificate_file(X509 *peercert) return false; } - while (PEM_read_X509(fp, &cert, NULL, NULL) != NULL) + while (PEM_read_X509(fp, &cert, NULL, NULL)) { if (compare_certificates(cert, peercert, peermd, peermdlen) && check_certificate_expiration(cert, true)) @@ -1139,7 +1139,7 @@ static int ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx) * In this case, all following certificates need to be treated as non-verified * until one is actually verified. */ - skip_mode = (SSL_get_ex_data(ssl, SkipModeExDataIndex) != NULL); + skip_mode = (SSL_get_ex_data(ssl, SkipModeExDataIndex)); cert = X509_STORE_CTX_get_current_cert(ctx); pos = X509_STORE_CTX_get_error_depth(ctx); diff --git a/conn/ssl_gnutls.c b/conn/ssl_gnutls.c index a29aa1802..3763b5bf8 100644 --- a/conn/ssl_gnutls.c +++ b/conn/ssl_gnutls.c @@ -310,7 +310,7 @@ static int tls_check_stored_hostname(const gnutls_datum_t *cert, const char *hos char buf[80]; buf[0] = '\0'; tls_fingerprint(GNUTLS_DIG_MD5, buf, sizeof(buf), cert); - while ((linestr = mutt_file_read_line(linestr, &linestrsize, fp, &linenum, 0)) != NULL) + while ((linestr = mutt_file_read_line(linestr, &linestrsize, fp, &linenum, 0))) { if (linestr[0] == '#' && linestr[1] == 'H') { diff --git a/curs_main.c b/curs_main.c index 9b2378002..dd6de7407 100644 --- a/curs_main.c +++ b/curs_main.c @@ -199,7 +199,7 @@ static void collapse_all(struct Menu *menu, int toggle) /* Iterate all threads, perform collapse/uncollapse as needed */ top = Context->tree; Context->collapsed = toggle ? !Context->collapsed : true; - while ((thread = top) != NULL) + while ((thread = top)) { while (!thread->message) thread = thread->child; diff --git a/edit.c b/edit.c index d471fa69d..dda2d5b4c 100644 --- a/edit.c +++ b/edit.c @@ -208,7 +208,7 @@ static char **be_include_messages(char *msg, char **buf, int *bufmax, if (!msg || !buf || !bufmax || !buflen) return buf; - while ((msg = strtok(msg, " ,")) != NULL) + while ((msg = strtok(msg, " ,"))) { if (mutt_str_atoi(msg, &n) == 0 && n > 0 && n <= Context->msgcount) { diff --git a/email/address.c b/email/address.c index 2b2160d0f..55b6ba0dc 100644 --- a/email/address.c +++ b/email/address.c @@ -637,7 +637,7 @@ struct Address *mutt_addr_parse_list2(struct Address *p, const char *s) mutt_str_strfcpy(tmp, s, sizeof(tmp)); char *r = tmp; - while ((r = strtok(r, " \t")) != NULL) + while ((r = strtok(r, " \t"))) { p = mutt_addr_parse_list(p, r); r = NULL; diff --git a/email/idna.c b/email/idna.c index 491dbf20d..01057904f 100644 --- a/email/idna.c +++ b/email/idna.c @@ -83,7 +83,7 @@ static bool check_idn(char *domain) if (mutt_str_strncasecmp(domain, "xn--", 4) == 0) return true; - while ((domain = strchr(domain, '.')) != NULL) + while ((domain = strchr(domain, '.'))) { if (mutt_str_strncasecmp(++domain, "xn--", 4) == 0) return true; diff --git a/email/mime.h b/email/mime.h index 5253f7fc4..2047841e9 100644 --- a/email/mime.h +++ b/email/mime.h @@ -74,13 +74,13 @@ extern const char MimeSpecials[]; #define hexval(c) IndexHex[(unsigned int) (c)] -#define is_multipart(x) \ +#define is_multipart(x) \ (((x)->type == TYPE_MULTIPART) || (((x)->type == TYPE_MESSAGE) && ((x)->subtype) && \ - ((strcasecmp((x)->subtype, "rfc822") == 0) || \ - (strcasecmp((x)->subtype, "news") == 0)))) + ((strcasecmp((x)->subtype, "rfc822") == 0) || \ + (strcasecmp((x)->subtype, "news") == 0)))) #define TYPE(X) \ - ((X->type == TYPE_OTHER) && (X->xtype != NULL) ? X->xtype : BodyTypes[(X->type)]) + ((X->type == TYPE_OTHER) && X->xtype ? X->xtype : BodyTypes[(X->type)]) #define ENCODING(X) BodyEncodings[(X)] #endif /* _EMAIL_MIME_H */ diff --git a/email/parse.c b/email/parse.c index 5c0e91124..890821971 100644 --- a/email/parse.c +++ b/email/parse.c @@ -304,7 +304,7 @@ char *mutt_extract_message_id(const char *s, const char **saveptr) else return NULL; - for (s = NULL, o = NULL, onull = NULL; (p = strpbrk(p, "<> \t;")) != NULL; ++p) + for (s = NULL, o = NULL, onull = NULL; (p = strpbrk(p, "<> \t;")); ++p) { if (*p == '<') { diff --git a/email/rfc2047.c b/email/rfc2047.c index db87493a8..162b87858 100644 --- a/email/rfc2047.c +++ b/email/rfc2047.c @@ -767,7 +767,7 @@ void rfc2047_decode_addrlist(struct Address *a) while (a) { if (a->personal && - ((strstr(a->personal, "=?") != NULL) || (AssumedCharset && *AssumedCharset))) + ((strstr(a->personal, "=?")) || (AssumedCharset && *AssumedCharset))) { rfc2047_decode(&a->personal); } diff --git a/email/thread.c b/email/thread.c index 0b7e8480b..d7709de27 100644 --- a/email/thread.c +++ b/email/thread.c @@ -197,7 +197,7 @@ void clean_references(struct MuttThread *brk, struct MuttThread *cur) /* clearing the References: header from obsolete Message-ID(s) */ struct ListNode *np = NULL; - while ((np = STAILQ_NEXT(ref, entries)) != NULL) + while ((np = STAILQ_NEXT(ref, entries))) { STAILQ_REMOVE_AFTER(&cur->message->env->references, ref, entries); FREE(&np->data); diff --git a/handler.c b/handler.c index 0e4aaafb6..bf70ec1af 100644 --- a/handler.c +++ b/handler.c @@ -438,7 +438,7 @@ static bool is_mmnoask(const char *buf) mutt_str_strfcpy(tmp, val, sizeof(tmp)); p = tmp; - while ((p = strtok(p, ",")) != NULL) + while ((p = strtok(p, ","))) { q = strrchr(p, '/'); if (q) @@ -592,7 +592,7 @@ static int autoview_handler(struct Body *a, struct State *s) if (s->prefix) { - while (fgets(buffer, sizeof(buffer), fpout) != NULL) + while (fgets(buffer, sizeof(buffer), fpout)) { state_puts(s->prefix, s); state_puts(buffer, s); @@ -608,7 +608,7 @@ static int autoview_handler(struct Body *a, struct State *s) state_puts(s->prefix, s); state_puts(buffer, s); - while (fgets(buffer, sizeof(buffer), fperr) != NULL) + while (fgets(buffer, sizeof(buffer), fperr)) { state_puts(s->prefix, s); state_puts(buffer, s); diff --git a/hcache/hcache.c b/hcache/hcache.c index 6de331386..e5f5fc41d 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -485,5 +485,5 @@ const char *mutt_hcache_backend_list(void) */ bool mutt_hcache_is_valid_backend(const char *s) { - return hcache_get_backend_ops(s) != NULL; + return hcache_get_backend_ops(s); } diff --git a/hcache/serialize.c b/hcache/serialize.c index 267457ee7..34c1b7734 100644 --- a/hcache/serialize.c +++ b/hcache/serialize.c @@ -66,7 +66,7 @@ static void lazy_realloc(void *ptr, size_t size) { void **p = (void **) ptr; - if (p != NULL && size < 4096) + if (p && (size < 4096)) return; mutt_mem_realloc(ptr, size); diff --git a/init.c b/init.c index 29cd3466a..4cd780dac 100644 --- a/init.c +++ b/init.c @@ -246,7 +246,7 @@ static int complete_all_nm_tags(const char *pt) /* Free the old list, if any. */ if (nm_tags) { - for (int i = 0; nm_tags[i] != NULL; i++) + for (int i = 0; nm_tags[i]; i++) FREE(&nm_tags[i]); FREE(&nm_tags); } @@ -836,7 +836,7 @@ static int source_rc(const char *rcfile_path, struct Buffer *err) } mutt_buffer_init(&token); - while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, MUTT_CONT)) != NULL) + while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, MUTT_CONT))) { const int conv = ConfigCharset && (*ConfigCharset) && Charset; if (conv) diff --git a/mailbox.c b/mailbox.c index 38feba5a2..8fbe1a1fe 100644 --- a/mailbox.c +++ b/mailbox.c @@ -242,7 +242,7 @@ static int mailbox_maildir_check_dir(struct Mailbox *mailbox, const char *dir_na return 0; } - while ((de = readdir(dirp)) != NULL) + while ((de = readdir(dirp))) { if (*de->d_name == '.') continue; @@ -354,7 +354,7 @@ static int mailbox_mbox_check(struct Mailbox *mailbox, struct stat *sb, bool che if (check_stats && (mailbox->stats_last_checked < sb->st_mtime)) { if (mx_mbox_open(mailbox->path, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK, - &ctx) != NULL) + &ctx)) { mailbox->msg_count = ctx.msgcount; mailbox->msg_unread = ctx.unread; diff --git a/maildir/mh.c b/maildir/mh.c index aa610a053..f94bd5723 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -414,7 +414,7 @@ bool mh_mailbox(struct Mailbox *mailbox, bool check_stats) dirp = opendir(mailbox->path); if (dirp) { - while ((de = readdir(dirp)) != NULL) + while ((de = readdir(dirp))) { if (*de->d_name == '.') continue; @@ -968,7 +968,7 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last, if (!dirp) return -1; - while (((de = readdir(dirp)) != NULL) && (SigInt != 1)) + while (((de = readdir(dirp))) && (SigInt != 1)) { if ((ctx->magic == MUTT_MH && !mh_valid_message(de->d_name)) || (ctx->magic == MUTT_MAILDIR && *de->d_name == '.')) @@ -1364,7 +1364,7 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md, void *data = mutt_hcache_fetch(hc, key, keylen); struct timeval *when = (struct timeval *) data; - if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec) + if (data && !ret && lastchanged.st_mtime <= when->tv_sec) { struct Header *h = mutt_hcache_restore((unsigned char *) data); h->old = p->h->old; @@ -1928,7 +1928,7 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg, } /* figure out what the next message number is */ - while ((de = readdir(dirp)) != NULL) + while ((de = readdir(dirp))) { dep = de->d_name; if (*dep == ',') diff --git a/mbox/mbox.c b/mbox/mbox.c index 5fa8503e0..23e23f1a6 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -304,7 +304,7 @@ static int mbox_parse_mailbox(struct Context *ctx) } loc = ftello(ctx->fp); - while ((fgets(buf, sizeof(buf), ctx->fp) != NULL) && (SigInt != 1)) + while ((fgets(buf, sizeof(buf), ctx->fp)) && (SigInt != 1)) { if (is_from(buf, return_path, sizeof(return_path), &t)) { @@ -842,7 +842,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint) char buffer[LONG_STRING]; if (fseeko(ctx->fp, ctx->size, SEEK_SET) != 0) mutt_debug(1, "#1 fseek() failed\n"); - if (fgets(buffer, sizeof(buffer), ctx->fp) != NULL) + if (fgets(buffer, sizeof(buffer), ctx->fp)) { if ((ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buffer, 5) == 0)) || (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buffer) == 0))) diff --git a/mutt/charset.c b/mutt/charset.c index c0f7e7a2f..edafdff7d 100644 --- a/mutt/charset.c +++ b/mutt/charset.c @@ -1003,7 +1003,7 @@ char *mutt_ch_choose(const char *fromcode, const char *charsets, char *u, t[n] = '\0'; s = mutt_str_substr_dup(u, u + ulen); - const int rc = (d != NULL) ? mutt_ch_convert_string(&s, fromcode, t, 0) : + const int rc = d ? mutt_ch_convert_string(&s, fromcode, t, 0) : mutt_ch_check(s, ulen, fromcode, t); if (rc) { diff --git a/mutt/date.c b/mutt/date.c index b32fd71b6..b066bedb1 100644 --- a/mutt/date.c +++ b/mutt/date.c @@ -470,7 +470,7 @@ time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) memset(&tm, 0, sizeof(tm)); - while ((t = strtok(t, " \t")) != NULL) + while ((t = strtok(t, " \t"))) { switch (count) { diff --git a/mutt/history.c b/mutt/history.c index 83b7e6897..e29e9f1c3 100644 --- a/mutt/history.c +++ b/mutt/history.c @@ -221,7 +221,7 @@ static void shrink_histfile(void) dup_hashes[hclass] = mutt_hash_create(MAX(10, SaveHistory * 2), MUTT_HASH_STRDUP_KEYS); line = 0; - while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0)) != NULL) + while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0))) { if (sscanf(linebuf, "%d:%n", &hclass, &read) < 1 || read == 0 || *(p = linebuf + strlen(linebuf) - 1) != '|' || hclass < 0) @@ -263,7 +263,7 @@ static void shrink_histfile(void) } rewind(f); line = 0; - while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0)) != NULL) + while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0))) { if (sscanf(linebuf, "%d:%n", &hclass, &read) < 1 || read == 0 || *(p = linebuf + strlen(linebuf) - 1) != '|' || hclass < 0) @@ -289,7 +289,7 @@ cleanup: FREE(&linebuf); if (tmpfp) { - if (fflush(tmpfp) == 0 && (f = fopen(HistoryFile, "w")) != NULL) + if ((fflush(tmpfp) == 0) && (f = fopen(HistoryFile, "w"))) { rewind(tmpfp); mutt_file_copy_stream(tmpfp, f); @@ -593,7 +593,7 @@ void mutt_hist_read_file(void) if (!f) return; - while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0)) != NULL) + while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0))) { read = 0; if (sscanf(linebuf, "%d:%n", &hclass, &read) < 1 || read == 0 || diff --git a/mutt/logging.c b/mutt/logging.c index 13d372bba..76ccbe893 100644 --- a/mutt/logging.c +++ b/mutt/logging.c @@ -214,7 +214,7 @@ void log_file_set_version(const char *version) */ bool log_file_running(void) { - return LogFileFP != NULL; + return LogFileFP; } /** diff --git a/mutt/mbyte.c b/mutt/mbyte.c index 48ab891e0..620c1812a 100644 --- a/mutt/mbyte.c +++ b/mutt/mbyte.c @@ -332,7 +332,7 @@ size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, char *buf) bool mutt_mb_is_shell_char(wchar_t ch) { static const wchar_t shell_chars[] = L"<>&()$?*;{}| "; /* ! not included because it can be part of a pathname in NeoMutt */ - return wcschr(shell_chars, ch) != NULL; + return wcschr(shell_chars, ch); } /** diff --git a/mutt/string.c b/mutt/string.c index a8698e02f..9b872f7cb 100644 --- a/mutt/string.c +++ b/mutt/string.c @@ -681,7 +681,7 @@ char *mutt_str_skip_email_wsp(const char *s) */ bool mutt_str_is_email_wsp(char c) { - return c && (strchr(EMAIL_WSP, c) != NULL); + return c && (strchr(EMAIL_WSP, c)); } /** diff --git a/mutt_header.c b/mutt_header.c index db983849b..4ab10c879 100644 --- a/mutt_header.c +++ b/mutt_header.c @@ -126,7 +126,7 @@ int mutt_label_message(struct Header *hdr) return 0; *buf = '\0'; - if (hdr != NULL && hdr->env->x_label != NULL) + if (hdr && hdr->env->x_label) { mutt_str_strfcpy(buf, hdr->env->x_label, sizeof(buf)); } diff --git a/mutt_parse.c b/mutt_parse.c index d0f678e12..f4e83c45b 100644 --- a/mutt_parse.c +++ b/mutt_parse.c @@ -119,7 +119,7 @@ static int count_body_parts(struct Body *body, int flags) if (!body) return 0; - for (struct Body *bp = body; bp != NULL; bp = bp->next) + for (struct Body *bp = body; bp; bp = bp->next) { /* Initial disposition is to count and not to recurse this part. */ bool shallcount = true; /* default */ diff --git a/mx.c b/mx.c index 9f05f7891..cafc57c87 100644 --- a/mx.c +++ b/mx.c @@ -289,7 +289,7 @@ enum MailboxType mx_get_magic(const char *path) else return MUTT_MBOX; } - else if ((f = fopen(path, "r")) != NULL) + else if ((f = fopen(path, "r"))) { struct utimbuf times; int ch; @@ -656,7 +656,7 @@ static int trash_append(struct Context *ctx) } #endif - if (mx_mbox_open(Trash, MUTT_APPEND, &ctx_trash) != NULL) + if (mx_mbox_open(Trash, MUTT_APPEND, &ctx_trash)) { /* continue from initial scan above */ for (i = first_del; i < ctx->msgcount; i++) diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 66e81cfb0..57ec06912 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -2496,8 +2496,8 @@ static void copy_clearsigned(gpgme_data_t data, struct State *s, char *charset) */ struct FgetConv *fc = mutt_ch_fgetconv_open(fp, charset, Charset, MUTT_ICONV_HOOK_FROM); - for (complete = true, armor_header = true; mutt_ch_fgetconvs(buf, sizeof(buf), fc) != NULL; - complete = (strchr(buf, '\n') != NULL)) + for (complete = true, armor_header = true; mutt_ch_fgetconvs(buf, sizeof(buf), fc); + complete = (strchr(buf, '\n'))) { if (!complete) { diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 2ea5cea5a..70f3900ce 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -257,7 +257,7 @@ static int pgp_copy_checksig(FILE *fpin, FILE *fpout) int lineno = 0; size_t linelen; - while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0)) != NULL) + while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0))) { if (regexec(PgpGoodSign->regex, line, 0, NULL, 0) == 0) { @@ -304,7 +304,7 @@ static int pgp_check_pgp_decryption_okay_regex(FILE *fpin) int lineno = 0; size_t linelen; - while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0)) != NULL) + while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0))) { if (regexec(PgpDecryptionOkay->regex, line, 0, NULL, 0) == 0) { @@ -357,7 +357,7 @@ static int pgp_check_decryption_okay(FILE *fpin) if (!PgpCheckGpgDecryptStatusFd) return pgp_check_pgp_decryption_okay_regex(fpin); - while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0)) != NULL) + while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0))) { if (mutt_str_strncmp(line, "[GNUPG:] ", 9) != 0) continue; @@ -423,8 +423,8 @@ static void pgp_copy_clearsigned(FILE *fpin, struct State *s, char *charset) */ struct FgetConv *fc = mutt_ch_fgetconv_open(fpin, charset, Charset, MUTT_ICONV_HOOK_FROM); - for (complete = true, armor_header = true; mutt_ch_fgetconvs(buf, sizeof(buf), fc) != NULL; - complete = (strchr(buf, '\n') != NULL)) + for (complete = true, armor_header = true; mutt_ch_fgetconvs(buf, sizeof(buf), fc); + complete = (strchr(buf, '\n'))) { if (!complete) { @@ -537,7 +537,7 @@ int pgp_class_application_handler(struct Body *m, struct State *s) } fputs(buf, tmpfp); - while (bytes > 0 && fgets(buf, sizeof(buf) - 1, s->fpin) != NULL) + while (bytes > 0 && fgets(buf, sizeof(buf) - 1, s->fpin)) { offset = ftello(s->fpin); bytes -= (offset - last_pos); /* don't rely on mutt_str_strlen(buf) */ @@ -1043,7 +1043,7 @@ static struct Body *pgp_decrypt_part(struct Body *a, struct State *s, /* Read the output from PGP, and make sure to change CRLF to LF, otherwise * read_mime_header has a hard time parsing the message. */ - while (fgets(buf, sizeof(buf) - 1, pgpout) != NULL) + while (fgets(buf, sizeof(buf) - 1, pgpout)) { size_t len = mutt_str_strlen(buf); if (len > 1 && buf[len - 2] == '\r') @@ -1306,7 +1306,7 @@ struct Body *pgp_class_sign_message(struct Body *a) /* Read back the PGP signature. Also, change MESSAGE=>SIGNATURE as * recommended for future releases of PGP. */ - while (fgets(buffer, sizeof(buffer) - 1, pgpout) != NULL) + while (fgets(buffer, sizeof(buffer) - 1, pgpout)) { if (mutt_str_strcmp("-----BEGIN PGP MESSAGE-----\n", buffer) == 0) fputs("-----BEGIN PGP SIGNATURE-----\n", fp); @@ -1319,7 +1319,7 @@ struct Body *pgp_class_sign_message(struct Body *a) /* check for errors from PGP */ err = false; - while (fgets(buffer, sizeof(buffer) - 1, pgperr) != NULL) + while (fgets(buffer, sizeof(buffer) - 1, pgperr)) { err = true; fputs(buffer, stdout); @@ -1580,7 +1580,7 @@ struct Body *pgp_class_encrypt_message(struct Body *a, char *keylist, bool sign) fflush(pgperr); rewind(pgperr); - while (fgets(buf, sizeof(buf) - 1, pgperr) != NULL) + while (fgets(buf, sizeof(buf) - 1, pgperr)) { err = 1; fputs(buf, stdout); diff --git a/ncrypt/pgpmicalg.c b/ncrypt/pgpmicalg.c index 39e4c5bca..c0c204e51 100644 --- a/ncrypt/pgpmicalg.c +++ b/ncrypt/pgpmicalg.c @@ -78,7 +78,7 @@ static void pgp_dearmor(FILE *in, FILE *out) /* find the beginning of ASCII armor */ - while ((r = fgets(line, sizeof(line), in)) != NULL) + while ((r = fgets(line, sizeof(line), in))) { if (strncmp(line, "-----BEGIN", 10) == 0) break; @@ -91,7 +91,7 @@ static void pgp_dearmor(FILE *in, FILE *out) /* skip the armor header */ - while ((r = fgets(line, sizeof(line), in)) != NULL) + while ((r = fgets(line, sizeof(line), in))) { SKIPWS(r); if (!*r) @@ -110,7 +110,7 @@ static void pgp_dearmor(FILE *in, FILE *out) /* find the checksum */ - while ((r = fgets(line, sizeof(line), in)) != NULL) + while ((r = fgets(line, sizeof(line), in))) { if (*line == '=' || (strncmp(line, "-----END", 8) == 0)) break; diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 115d2cfa9..24c95c3c5 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -1624,7 +1624,7 @@ struct Body *smime_class_build_smime_entity(struct Body *a, char *certlist) fflush(smimeerr); rewind(smimeerr); - while (fgets(buf, sizeof(buf) - 1, smimeerr) != NULL) + while (fgets(buf, sizeof(buf) - 1, smimeerr)) { err = 1; fputs(buf, stdout); @@ -1773,7 +1773,7 @@ struct Body *smime_class_sign_message(struct Body *a) err = 0; fflush(smimeerr); rewind(smimeerr); - while (fgets(buffer, sizeof(buffer) - 1, smimeerr) != NULL) + while (fgets(buffer, sizeof(buffer) - 1, smimeerr)) { err = 1; fputs(buffer, stdout); @@ -2130,7 +2130,7 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o } } char buf[HUGE_STRING]; - while (fgets(buf, sizeof(buf) - 1, smimeout) != NULL) + while (fgets(buf, sizeof(buf) - 1, smimeout)) { const size_t len = mutt_str_strlen(buf); if (len > 1 && buf[len - 2] == '\r') diff --git a/pager.c b/pager.c index 09f62064f..ce05d5361 100644 --- a/pager.c +++ b/pager.c @@ -1142,7 +1142,7 @@ static int grok_ansi(unsigned char *buf, int pos, struct AnsiAttr *a) x++; /* Character Attributes */ - if (AllowAnsi && a != NULL && buf[x] == 'm') + if (AllowAnsi && a && (buf[x] == 'm')) { if (pos == x) { diff --git a/query.c b/query.c index b25061022..cecc89f43 100644 --- a/query.c +++ b/query.c @@ -153,7 +153,7 @@ static struct Query *run_query(char *s, int quiet) p = strrchr(msg, '\n'); if (p) *p = '\0'; - while ((buf = mutt_file_read_line(buf, &buflen, fp, &dummy, 0)) != NULL) + while ((buf = mutt_file_read_line(buf, &buflen, fp, &dummy, 0))) { p = strtok(buf, "\t\n"); if (p) diff --git a/recvattach.c b/recvattach.c index 15f19297d..6049c543a 100644 --- a/recvattach.c +++ b/recvattach.c @@ -612,7 +612,7 @@ void mutt_save_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, if (mutt_check_overwrite(top->filename, buf, tfile, sizeof(tfile), &append, NULL)) return; rc = mutt_save_attachment(fp, top, tfile, append, hdr); - if (rc == 0 && AttachSep && (fpout = fopen(tfile, "a")) != NULL) + if ((rc == 0) && AttachSep && (fpout = fopen(tfile, "a"))) { fprintf(fpout, "%s", AttachSep); mutt_file_fclose(&fpout); @@ -621,7 +621,7 @@ void mutt_save_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, else { rc = mutt_save_attachment(fp, top, tfile, MUTT_SAVE_APPEND, hdr); - if (rc == 0 && AttachSep && (fpout = fopen(tfile, "a")) != NULL) + if ((rc == 0) && AttachSep && (fpout = fopen(tfile, "a"))) { fprintf(fpout, "%s", AttachSep); mutt_file_fclose(&fpout); diff --git a/rfc1524.c b/rfc1524.c index 4c165ed11..3a9b0b5d2 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -110,7 +110,7 @@ int rfc1524_expand_command(struct Body *a, char *filename, char *type, char *com y += mutt_file_quote_filename(buf + y, sizeof(buf) - y, pvalue); } - else if (command[x] == 's' && filename != NULL) + else if (command[x] == 's' && filename) { y += mutt_file_quote_filename(buf + y, sizeof(buf) - y, filename); needspipe = false; @@ -143,7 +143,7 @@ static char *get_field(char *s) if (!s) return NULL; - while ((ch = strpbrk(s, ";\\")) != NULL) + while ((ch = strpbrk(s, ";\\"))) { if (*ch == '\\') { @@ -231,7 +231,7 @@ static int rfc1524_mailcap_parse(struct Body *a, char *filename, char *type, if (fp) { size_t buflen; - while (!found && (buf = mutt_file_read_line(buf, &buflen, fp, &line, MUTT_CONT)) != NULL) + while (!found && (buf = mutt_file_read_line(buf, &buflen, fp, &line, MUTT_CONT))) { /* ignore comments */ if (*buf == '#') diff --git a/sendlib.c b/sendlib.c index 5f45b3d6a..b4b2629eb 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1006,7 +1006,7 @@ struct Content *mutt_get_content_info(const char *fname, struct Body *b) info = mutt_mem_calloc(1, sizeof(struct Content)); - if (b != NULL && b->type == TYPE_TEXT && (!b->noconv && !b->force_charset)) + if (b && b->type == TYPE_TEXT && (!b->noconv && !b->force_charset)) { char *chs = mutt_param_get(&b->parameter, "charset"); char *fchs = b->use_disp ? @@ -1037,7 +1037,7 @@ struct Content *mutt_get_content_info(const char *fname, struct Body *b) mutt_file_fclose(&fp); - if (b != NULL && b->type == TYPE_TEXT && (!b->noconv && !b->force_charset)) + if (b && b->type == TYPE_TEXT && (!b->noconv && !b->force_charset)) { mutt_param_set(&b->parameter, "charset", (!info->hibin ? "us-ascii" : @@ -1107,7 +1107,7 @@ int mutt_lookup_mime_type(struct Body *att, const char *path) { found_mimetypes = true; - while (fgets(buf, sizeof(buf) - 1, f) != NULL) + while (fgets(buf, sizeof(buf) - 1, f)) { /* weed out any comments */ p = strchr(buf, '#'); @@ -3127,7 +3127,7 @@ int mutt_write_multiple_fcc(const char *path, struct Header *hdr, const char *ms if (status != 0) return status; - while ((tok = strtok(NULL, ",")) != NULL) + while ((tok = strtok(NULL, ","))) { if (!*tok) continue; @@ -3331,7 +3331,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid, /* count the number of lines */ rewind(tempfp); - while (fgets(sasha, sizeof(sasha), tempfp) != NULL) + while (fgets(sasha, sizeof(sasha), tempfp)) lines++; fprintf(msg->fp, "Content-Length: " OFF_T_FMT "\n", (LOFF_T) ftello(tempfp)); fprintf(msg->fp, "Lines: %d\n\n", lines); diff --git a/sort.c b/sort.c index 2c8ca592e..444ec7477 100644 --- a/sort.c +++ b/sort.c @@ -435,7 +435,7 @@ void mutt_sort_headers(struct Context *ctx, bool init) if ((Sort & SORT_MASK) == SORT_THREADS) { top = ctx->tree; - while ((thread = top) != NULL) + while ((thread = top)) { while (!thread->message) thread = thread->child;