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)
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;
}
/* 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;
/* 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;
{
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? */
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? */
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);
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)
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)
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;
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) */
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);
}
/* Find the next parameter */
- if ((*s != ';') && (s = strchr(s, ';')) == NULL)
+ if ((*s != ';') && !(s = strchr(s, ';')))
break; /* no more parameters */
do
regmatch_t match[4];
size_t nmatch = 4;
- if (re == NULL)
+ if (!re)
{
re = mutt_regex_compile("=\\?"
"([^][()<>@,;:\\\"/?. =]+)" /* charset */
* 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);
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]))
}
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)
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;
{
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);
}
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)
while (true)
{
- if (fgets(buf, sizeof(buf) - 1, ctx->fp) == NULL)
+ if (!fgets(buf, sizeof(buf) - 1, ctx->fp))
break;
if (SigInt == 1)
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");
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)
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);
* 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",
/* 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)
{
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)))
{
{
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;
while (true)
{
- if (fgets(s + offset, *size - offset, fp) == NULL)
+ if (!fgets(s + offset, *size - offset, fp))
{
FREE(&s);
return NULL;
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]);
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]);
{
char s[PATH_MAX];
- if (realpath(buf, s) == NULL)
+ if (!realpath(buf, s))
return 0;
return mutt_str_strfcpy(buf, s, sizeof(s));
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';
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)
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)
}
else
{
- if (lua_pushstring(l, err.data) == NULL)
+ if (!lua_pushstring(l, err.data))
handle_error(l);
else
rc++;
}
else
{
- if (lua_pushstring(l, err.data) == NULL)
+ if (!lua_pushstring(l, err.data))
handle_error(l);
else
rc++;
}
}
- 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))
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;
if (strlen(s) % 8)
return false;
while (*s)
- if (strchr("0123456789ABCDEFabcdef", *s++) == NULL)
+ if (!strchr("0123456789ABCDEFabcdef", *s++))
return false;
return true;
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);
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);
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;
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;
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;
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;
}
}
/* 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))
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);
/* 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 */
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 */
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,
}
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,
* 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)
{
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)
{
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?"));
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;
/* 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);
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)
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;
}
}
}
- 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;
}
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);
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;
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;
{
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;
}
}
/* 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)
#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;
}
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;