From: Richard Russon Date: Wed, 28 Mar 2018 19:16:13 +0000 (+0100) Subject: test int functions against 0 X-Git-Tag: neomutt-20180512~70^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f0c766e03d952c9a8c6348c17a63cf889669731;p=neomutt test int functions against 0 --- diff --git a/browser.c b/browser.c index c8f38b4ac..17eb750f4 100644 --- a/browser.c +++ b/browser.c @@ -1201,7 +1201,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi { init_state(&state, NULL); state.imap_browse = true; - if (!imap_browse(f, &state)) + if (imap_browse(f, &state) == 0) { mutt_str_strfcpy(LastDir, state.folder, sizeof(LastDir)); browser_sort(&state); @@ -1609,7 +1609,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi break; } - if (!imap_mailbox_create(LastDir)) + if (imap_mailbox_create(LastDir) == 0) { /* TODO: find a way to detect if the new folder would appear in * this window, and insert it without starting over. */ @@ -1669,7 +1669,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi snprintf(msg, sizeof(msg), _("Really delete mailbox \"%s\"?"), mx.mbox); if (mutt_yesorno(msg, MUTT_NO) == MUTT_YES) { - if (!imap_delete_mailbox(Context, &mx)) + if (imap_delete_mailbox(Context, &mx) == 0) { /* free the mailbox from the browser */ FREE(&((state.entry)[nentry].name)); diff --git a/color.c b/color.c index 71a7b5747..c4fdca841 100644 --- a/color.c +++ b/color.c @@ -727,7 +727,7 @@ static int parse_object(struct Buffer *buf, struct Buffer *s, int *o, int *ql, *o = MT_COLOR_QUOTED; } - else if (!mutt_str_strcasecmp(buf->data, "compose")) + else if (mutt_str_strcasecmp(buf->data, "compose") == 0) { if (!MoreArgs(s)) { diff --git a/commands.c b/commands.c index b8158eda1..9a5d83917 100644 --- a/commands.c +++ b/commands.c @@ -197,7 +197,7 @@ int mutt_display_message(struct Header *cur) { if (cur->security & GOODSIGN) { - if (!crypt_smime_verify_sender(cur)) + if (crypt_smime_verify_sender(cur) == 0) mutt_message(_("S/MIME signature successfully verified.")); else mutt_error(_("S/MIME certificate owner does not match sender.")); diff --git a/conn/getdomain.c b/conn/getdomain.c index c4729033d..40f416c9b 100644 --- a/conn/getdomain.c +++ b/conn/getdomain.c @@ -49,7 +49,7 @@ int getdnsdomainname(char *d, size_t len) #if defined(HAVE_GETADDRINFO) || defined(HAVE_GETADDRINFO_A) char node[STRING]; - if (gethostname(node, sizeof(node))) + if (gethostname(node, sizeof(node)) != 0) return rc; struct addrinfo hints; diff --git a/conn/ssl.c b/conn/ssl.c index 6ceb4f970..f6d8abcaf 100644 --- a/conn/ssl.c +++ b/conn/ssl.c @@ -1184,7 +1184,7 @@ static int ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx) buf[0] = 0; if (pos == 0 && SslVerifyHost != MUTT_NO) { - if (!check_host(cert, host, buf, sizeof(buf))) + if (check_host(cert, host, buf, sizeof(buf)) == 0) { mutt_error(_("Certificate host check failed: %s"), buf); /* we disallow (a)ccept always in the prompt, because it will have no effect diff --git a/conn/ssl_gnutls.c b/conn/ssl_gnutls.c index b39f8c7dc..2a02e0f33 100644 --- a/conn/ssl_gnutls.c +++ b/conn/ssl_gnutls.c @@ -572,7 +572,7 @@ static int tls_check_one_certificate(const gnutls_datum_t *certdata, gnutls_datum_t pemdata; int row, done, ret; - if (!tls_check_preauth(certdata, certstat, hostname, idx, &certerr, &savedcert)) + if (tls_check_preauth(certdata, certstat, hostname, idx, &certerr, &savedcert) == 0) return 1; /* skip signers if insecure algorithm was used */ @@ -1196,7 +1196,7 @@ static int tls_negotiate(struct Connection *conn) goto fail; } - if (!tls_check_certificate(conn)) + if (tls_check_certificate(conn) == 0) goto fail; /* set Security Strength Factor (SSF) for SASL */ diff --git a/copy.c b/copy.c index d1b8cb604..5602c09bb 100644 --- a/copy.c +++ b/copy.c @@ -172,7 +172,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, { if (flags & CH_DECODE) { - if (!address_header_decode(&this_one)) + if (address_header_decode(&this_one) == 0) mutt_rfc2047_decode(&this_one); this_one_len = mutt_str_strlen(this_one); @@ -289,7 +289,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, { if (flags & CH_DECODE) { - if (!address_header_decode(&this_one)) + if (address_header_decode(&this_one) == 0) mutt_rfc2047_decode(&this_one); this_one_len = mutt_str_strlen(this_one); } diff --git a/enter.c b/enter.c index 269a3ffdd..bcf639ac8 100644 --- a/enter.c +++ b/enter.c @@ -489,7 +489,7 @@ int mutt_enter_string_full(char *buf, size_t buflen, int col, int flags, int mul rc = 1; goto bye; } - if (!mutt_complete(buf, buflen)) + if (mutt_complete(buf, buflen) == 0) { templen = state->lastchar - i; mutt_mem_realloc(&tempbuf, templen * sizeof(wchar_t)); @@ -609,7 +609,7 @@ int mutt_enter_string_full(char *buf, size_t buflen, int col, int flags, int mul goto bye; } - if (!mutt_complete(buf, buflen)) + if (mutt_complete(buf, buflen) == 0) { templen = state->lastchar; mutt_mem_realloc(&tempbuf, templen * sizeof(wchar_t)); diff --git a/history.c b/history.c index 0c275f0be..4d88d55be 100644 --- a/history.c +++ b/history.c @@ -387,7 +387,7 @@ static void remove_history_dups(enum HistoryClass hclass, const char *str) source = dest = 0; while (source < h->last) { - if (!mutt_str_strcmp(h->hist[source], str)) + if (mutt_str_strcmp(h->hist[source], str) == 0) FREE(&h->hist[source++]); else h->hist[dest++] = h->hist[source++]; @@ -406,7 +406,7 @@ static void remove_history_dups(enum HistoryClass hclass, const char *str) source = dest = History; while (source > old_last) { - if (!mutt_str_strcmp(h->hist[source], str)) + if (mutt_str_strcmp(h->hist[source], str) == 0) FREE(&h->hist[source--]); else h->hist[dest--] = h->hist[source--]; diff --git a/imap/browse.c b/imap/browse.c index 4b1d5bd2a..bc4df448b 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -393,7 +393,7 @@ int imap_mailbox_create(const char *folder) if (mutt_get_field(_("Create mailbox: "), buf, sizeof(buf), MUTT_FILE) < 0) goto fail; - if (!mutt_str_strlen(buf)) + if (mutt_str_strlen(buf) == 0) { mutt_error(_("Mailbox must have a name.")); goto fail; @@ -453,7 +453,7 @@ int imap_mailbox_rename(const char *mailbox) if (mutt_get_field(buf, newname, sizeof(newname), MUTT_FILE) < 0) goto fail; - if (!mutt_str_strlen(newname)) + if (mutt_str_strlen(newname) == 0) { mutt_error(_("Mailbox must have a name.")); goto fail; diff --git a/imap/command.c b/imap/command.c index 3885ac8d5..0cd15fede 100644 --- a/imap/command.c +++ b/imap/command.c @@ -443,7 +443,7 @@ static void cmd_parse_list(struct ImapData *idata, char *s) /* Name */ s = imap_next_word(s); /* Notes often responds with literals here. We need a real tokenizer. */ - if (!imap_get_literal_count(s, &litlen)) + if (imap_get_literal_count(s, &litlen) == 0) { if (imap_cmd_step(idata) != IMAP_CMD_CONTINUE) { @@ -631,7 +631,7 @@ static void cmd_parse_status(struct ImapData *idata, char *s) mailbox = imap_next_word(s); /* We need a real tokenizer. */ - if (!imap_get_literal_count(mailbox, &litlen)) + if (imap_get_literal_count(mailbox, &litlen) == 0) { if (imap_cmd_step(idata) != IMAP_CMD_CONTINUE) { diff --git a/imap/imap.c b/imap/imap.c index 1a29c58da..12b458a50 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -46,6 +46,7 @@ #include "conn/conn.h" #include "mutt.h" #include "imap.h" +#include "auth.h" #include "bcache.h" #include "body.h" #include "buffy.h" @@ -412,7 +413,7 @@ static int do_search(const struct Pattern *search, int allpats) */ static int compile_search(struct Context *ctx, const struct Pattern *pat, struct Buffer *buf) { - if (!do_search(pat, 0)) + if (do_search(pat, 0) == 0) return 0; if (pat->not) @@ -971,7 +972,7 @@ struct ImapData *imap_conn_find(const struct Account *account, int flags) imap_open_connection(idata); if (idata->state == IMAP_CONNECTED) { - if (!imap_authenticate(idata)) + if (imap_authenticate(idata) == IMAP_AUTH_SUCCESS) { idata->state = IMAP_AUTHENTICATED; FREE(&idata->capstr); @@ -1678,7 +1679,7 @@ int imap_search(struct Context *ctx, const struct Pattern *pat) for (int i = 0; i < ctx->msgcount; i++) ctx->hdrs[i]->matched = false; - if (!do_search(pat, 1)) + if (do_search(pat, 1) == 0) return 0; mutt_buffer_init(&buf); @@ -1891,7 +1892,7 @@ int imap_fast_trash(struct Context *ctx, char *dest) } /* check that the save-to folder is in the same account */ - if (!mutt_account_match(&(idata->conn->account), &(mx.account))) + if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0) { mutt_debug(3, "%s not same server as %s\n", dest, ctx->path); return 1; diff --git a/imap/message.c b/imap/message.c index f9fa1653b..761be2c37 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1397,7 +1397,7 @@ int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int de } /* check that the save-to folder is in the same account */ - if (!mutt_account_match(&(idata->conn->account), &(mx.account))) + if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0) { mutt_debug(3, "%s not same server as %s\n", dest, ctx->path); return 1; diff --git a/main.c b/main.c index ddc57f7cd..db0840212 100644 --- a/main.c +++ b/main.c @@ -954,7 +954,7 @@ int main(int argc, char *argv[], char *envp[]) { if (flags & MUTT_BUFFY) { - if (!mutt_buffy_check(false)) + if (mutt_buffy_check(false) == 0) { mutt_message(_("No mailbox with new mail.")); goto main_curses; // TEST37: neomutt -Z (no new mail) diff --git a/mutt/rfc2047.c b/mutt/rfc2047.c index 685574368..537876967 100644 --- a/mutt/rfc2047.c +++ b/mutt/rfc2047.c @@ -512,7 +512,7 @@ static int rfc2047_encode(const char *d, size_t dlen, int col, const char *fromc if (icode) while ((t < (u + ulen)) && CONTINUATION_BYTE(*t)) t++; - if (!try_block(t0, t - t0, icode, tocode, &encoder, &wlen) && + if ((try_block(t0, t - t0, icode, tocode, &encoder, &wlen) == 0) && ((col + (t0 - u) + wlen) <= (ENCWORD_LEN_MAX + 1))) { break; @@ -528,7 +528,7 @@ static int rfc2047_encode(const char *d, size_t dlen, int col, const char *fromc if (icode) while (CONTINUATION_BYTE(*t)) t--; - if (!try_block(t, t1 - t, icode, tocode, &encoder, &wlen) && + if ((try_block(t, t1 - t, icode, tocode, &encoder, &wlen) == 0) && ((1 + wlen + (u + ulen - t1)) <= (ENCWORD_LEN_MAX + 1))) { break; diff --git a/mx.c b/mx.c index 18213060a..aa394d366 100644 --- a/mx.c +++ b/mx.c @@ -605,7 +605,7 @@ static int trash_append(struct Context *ctx) #ifdef USE_IMAP if (Context->magic == MUTT_IMAP && mx_is_imap(Trash)) { - if (!imap_fast_trash(Context, Trash)) + if (imap_fast_trash(Context, Trash) == 0) return 0; } #endif diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 77f4a8fe0..fafd8b605 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -154,7 +154,7 @@ int mutt_protect(struct Header *msg, char *keylist) return -1; } } - else if (!mutt_str_strcasecmp("flowed", mutt_param_get(&msg->content->parameter, "format"))) + else if (mutt_str_strcasecmp("flowed", mutt_param_get(&msg->content->parameter, "format")) == 0) { if ((query_quadoption(PgpMimeAuto, _("Inline PGP can't be used with format=flowed. " @@ -365,7 +365,7 @@ int mutt_is_multipart_encrypted(struct Body *b) int mutt_is_valid_multipart_pgp_encrypted(struct Body *b) { - if (!mutt_is_multipart_encrypted(b)) + if (mutt_is_multipart_encrypted(b) == 0) return 0; b = b->parts; diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 87e805b78..824d5cc99 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -1056,7 +1056,7 @@ static struct Body *sign_message(struct Body *a, int use_smime) use_smime ? "application/pkcs7-signature" : "application/pgp-signature"); /* Get the micalg from gpgme. Old gpgme versions don't support this for S/MIME so we assume sha-1 in this case. */ - if (!get_micalg(ctx, use_smime, buf, sizeof(buf))) + if (get_micalg(ctx, use_smime, buf, sizeof(buf)) == 0) mutt_param_set(&t->parameter, "micalg", buf); else if (use_smime) mutt_param_set(&t->parameter, "micalg", "sha1"); @@ -2026,7 +2026,7 @@ int smime_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Bo size_t saved_b_length; int saved_b_type; - if (!mutt_is_application_smime(b)) + if (mutt_is_application_smime(b) == 0) return -1; if (b->parts) diff --git a/status.c b/status.c index bb5fcb46f..2ac69fb44 100644 --- a/status.c +++ b/status.c @@ -108,7 +108,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, mutt_buffy_check(false)); } - else if (!mutt_buffy_check(false)) + else if (mutt_buffy_check(false) == 0) optional = 0; break; diff --git a/thread.c b/thread.c index 254a62fdc..353631791 100644 --- a/thread.c +++ b/thread.c @@ -634,7 +634,7 @@ struct MuttThread *mutt_sort_subthreads(struct MuttThread *thread, int init) * in reverse order so they're forwards */ Sort ^= SORT_REVERSE; - if (!compare_threads(NULL, NULL)) + if (compare_threads(NULL, NULL) == 0) return thread; top = thread;