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);
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;
}
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 . */
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? */
}
#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
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))
}
}
- while ((de = readdir(dirp)) != NULL)
+ while ((de = readdir(dirp)))
{
if (mutt_str_strncmp(de->d_name, filepart, len) == 0)
{
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
{
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)
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);
#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;
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))
* 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);
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')
{
/* 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;
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)
{
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;
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;
#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 */
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 == '<')
{
while (a)
{
if (a->personal &&
- ((strstr(a->personal, "=?") != NULL) || (AssumedCharset && *AssumedCharset)))
+ ((strstr(a->personal, "=?")) || (AssumedCharset && *AssumedCharset)))
{
rfc2047_decode(&a->personal);
}
/* 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);
mutt_str_strfcpy(tmp, val, sizeof(tmp));
p = tmp;
- while ((p = strtok(p, ",")) != NULL)
+ while ((p = strtok(p, ",")))
{
q = strrchr(p, '/');
if (q)
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);
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);
*/
bool mutt_hcache_is_valid_backend(const char *s)
{
- return hcache_get_backend_ops(s) != NULL;
+ return hcache_get_backend_ops(s);
}
{
void **p = (void **) ptr;
- if (p != NULL && size < 4096)
+ if (p && (size < 4096))
return;
mutt_mem_realloc(ptr, size);
/* 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);
}
}
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)
return 0;
}
- while ((de = readdir(dirp)) != NULL)
+ while ((de = readdir(dirp)))
{
if (*de->d_name == '.')
continue;
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;
dirp = opendir(mailbox->path);
if (dirp)
{
- while ((de = readdir(dirp)) != NULL)
+ while ((de = readdir(dirp)))
{
if (*de->d_name == '.')
continue;
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 == '.'))
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;
}
/* figure out what the next message number is */
- while ((de = readdir(dirp)) != NULL)
+ while ((de = readdir(dirp)))
{
dep = de->d_name;
if (*dep == ',')
}
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))
{
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)))
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)
{
memset(&tm, 0, sizeof(tm));
- while ((t = strtok(t, " \t")) != NULL)
+ while ((t = strtok(t, " \t")))
{
switch (count)
{
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)
}
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)
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);
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 ||
*/
bool log_file_running(void)
{
- return LogFileFP != NULL;
+ return LogFileFP;
}
/**
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);
}
/**
*/
bool mutt_str_is_email_wsp(char c)
{
- return c && (strchr(EMAIL_WSP, c) != NULL);
+ return c && (strchr(EMAIL_WSP, c));
}
/**
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));
}
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 */
else
return MUTT_MBOX;
}
- else if ((f = fopen(path, "r")) != NULL)
+ else if ((f = fopen(path, "r")))
{
struct utimbuf times;
int ch;
}
#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++)
*/
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)
{
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)
{
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)
{
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;
*/
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)
{
}
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) */
/* 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')
/* 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);
/* 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);
fflush(pgperr);
rewind(pgperr);
- while (fgets(buf, sizeof(buf) - 1, pgperr) != NULL)
+ while (fgets(buf, sizeof(buf) - 1, pgperr))
{
err = 1;
fputs(buf, stdout);
/* 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;
/* skip the armor header */
- while ((r = fgets(line, sizeof(line), in)) != NULL)
+ while ((r = fgets(line, sizeof(line), in)))
{
SKIPWS(r);
if (!*r)
/* 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;
fflush(smimeerr);
rewind(smimeerr);
- while (fgets(buf, sizeof(buf) - 1, smimeerr) != NULL)
+ while (fgets(buf, sizeof(buf) - 1, smimeerr))
{
err = 1;
fputs(buf, stdout);
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);
}
}
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')
x++;
/* Character Attributes */
- if (AllowAnsi && a != NULL && buf[x] == 'm')
+ if (AllowAnsi && a && (buf[x] == 'm'))
{
if (pos == x)
{
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)
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);
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);
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;
if (!s)
return NULL;
- while ((ch = strpbrk(s, ";\\")) != NULL)
+ while ((ch = strpbrk(s, ";\\")))
{
if (*ch == '\\')
{
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 == '#')
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 ?
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" :
{
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, '#');
if (status != 0)
return status;
- while ((tok = strtok(NULL, ",")) != NULL)
+ while ((tok = strtok(NULL, ",")))
{
if (!*tok)
continue;
/* 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);
if ((Sort & SORT_MASK) == SORT_THREADS)
{
top = ctx->tree;
- while ((thread = top) != NULL)
+ while ((thread = top))
{
while (!thread->message)
thread = thread->child;