From: Richard Russon Date: Thu, 14 Dec 2017 20:00:40 +0000 (+0000) Subject: split if's containing assignments X-Git-Tag: neomutt-20180223~66^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9cda4e2549c01e7b7c8b34aa98f38c2328ced0cb;p=neomutt split if's containing assignments --- diff --git a/address.c b/address.c index c3cd6427d..194b459e5 100644 --- a/address.c +++ b/address.c @@ -326,8 +326,9 @@ static const char *parse_route_addr(const char *s, char *comment, size_t *commen s++; } - if ((s = parse_address(s, token, &tokenlen, sizeof(token) - 1, comment, - commentlen, commentmax, addr)) == NULL) + s = parse_address(s, token, &tokenlen, sizeof(token) - 1, comment, commentlen, + commentmax, addr); + if (s == NULL) return NULL; if (*s != '>') @@ -500,7 +501,8 @@ struct Address *mutt_addr_parse_list(struct Address *top, const char *s) last = last->next; ws_pending = mutt_str_is_email_wsp(*s); - if ((nl = mutt_str_strlen(s))) + nl = mutt_str_strlen(s); + if (nl) nl = s[nl - 1] == '\n'; s = mutt_str_skip_email_wsp(s); diff --git a/alias.c b/alias.c index d028ec85b..e3041cbc1 100644 --- a/alias.c +++ b/alias.c @@ -302,7 +302,8 @@ void mutt_create_alias(struct Envelope *cur, struct Address *iadr) if (adr && adr->mailbox) { mutt_str_strfcpy(tmp, adr->mailbox, sizeof(tmp)); - if ((pc = strchr(tmp, '@'))) + pc = strchr(tmp, '@'); + if (pc) *pc = '\0'; } else @@ -389,7 +390,8 @@ retry_name: mutt_alias_add_reverse(new); - if ((t = Aliases)) + t = Aliases; + if (t) { while (t->next) t = t->next; @@ -402,7 +404,8 @@ retry_name: if (mutt_get_field(_("Save to file: "), buf, sizeof(buf), MUTT_FILE) != 0) return; mutt_expand_path(buf, sizeof(buf)); - if ((rc = fopen(buf, "a+"))) + rc = fopen(buf, "a+"); + if (rc) { /* terminate existing file with \n if necessary */ if (fseek(rc, 0, SEEK_END)) diff --git a/attach.c b/attach.c index 87d1a7e0d..93f8c2092 100644 --- a/attach.c +++ b/attach.c @@ -498,8 +498,9 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr, goto return_error; } - if ((thepid = mutt_create_filter_fd(command, NULL, NULL, NULL, use_pipe ? tempfd : -1, - use_pager ? pagerfd : -1, -1)) == -1) + thepid = mutt_create_filter_fd(command, NULL, NULL, NULL, use_pipe ? tempfd : -1, + use_pager ? pagerfd : -1, -1); + if (thepid == -1) { if (pagerfd != -1) close(pagerfd); diff --git a/browser.c b/browser.c index faac9dc27..933bd9d82 100644 --- a/browser.c +++ b/browser.c @@ -426,7 +426,8 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c case 'g': if (folder->ff->local) { - if ((gr = getgrgid(folder->ff->gid))) + gr = getgrgid(folder->ff->gid); + if (gr) mutt_format_s(buf, buflen, prec, gr->gr_name); else { @@ -502,7 +503,8 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c case 'u': if (folder->ff->local) { - if ((pw = getpwuid(folder->ff->uid))) + pw = getpwuid(folder->ff->uid); + if (pw) mutt_format_s(buf, buflen, prec, pw->pw_name); else { diff --git a/buffy.c b/buffy.c index db32d86b6..d6982ad32 100644 --- a/buffy.c +++ b/buffy.c @@ -146,7 +146,8 @@ static int test_new_folder(const char *path) if (typ != MUTT_MBOX && typ != MUTT_MMDF) return 0; - if ((f = fopen(path, "rb"))) + f = fopen(path, "rb"); + if (f) { rc = test_last_status_new(f); mutt_file_fclose(&f); diff --git a/complete.c b/complete.c index 9af2fbc84..e85429de3 100644 --- a/complete.c +++ b/complete.c @@ -148,7 +148,8 @@ int mutt_complete(char *s, size_t slen) mutt_str_strfcpy(exp_dirpart, NONULL(SpoolFile), sizeof(exp_dirpart)); else mutt_str_strfcpy(exp_dirpart, NONULL(Folder), sizeof(exp_dirpart)); - if ((p = strrchr(s, '/'))) + p = strrchr(s, '/'); + if (p) { char buf[_POSIX_PATH_MAX]; if (mutt_file_concatn_path(buf, sizeof(buf), exp_dirpart, strlen(exp_dirpart), @@ -166,7 +167,8 @@ int mutt_complete(char *s, size_t slen) } else { - if ((p = strrchr(s, '/'))) + p = strrchr(s, '/'); + if (p) { if (p == s) /* absolute path */ { diff --git a/compose.c b/compose.c index df0b79b06..e69e58c63 100644 --- a/compose.c +++ b/compose.c @@ -666,7 +666,8 @@ static unsigned long cum_attachs_size(struct Menu *menu) if (!b->content) b->content = mutt_get_content_info(b->filename, b); - if ((info = b->content)) + info = b->content; + if (info) { switch (b->encoding) { @@ -1319,8 +1320,8 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ if (!fcc_set && *fcc) { - if ((i = query_quadoption(OPT_COPY, - _("Save a copy of this message?"))) == MUTT_ABORT) + i = query_quadoption(OPT_COPY, _("Save a copy of this message?")); + if (i == MUTT_ABORT) break; else if (i == MUTT_NO) *fcc = 0; diff --git a/conn/ssl.c b/conn/ssl.c index 79e006b4b..298f32666 100644 --- a/conn/ssl.c +++ b/conn/ssl.c @@ -839,7 +839,8 @@ static int check_host(X509 *x509cert, const char *hostname, char *err, size_t er /* Try the DNS subjectAltNames. */ match_found = false; - if ((subj_alt_names = X509_get_ext_d2i(x509cert, NID_subject_alt_name, NULL, NULL))) + subj_alt_names = X509_get_ext_d2i(x509cert, NID_subject_alt_name, NULL, NULL); + if (subj_alt_names) { subj_alt_names_count = sk_GENERAL_NAME_num(subj_alt_names); for (int i = 0; i < subj_alt_names_count; i++) @@ -1069,7 +1070,8 @@ static int interactive_check_cert(X509 *cert, int idx, size_t len, SSL *ssl, int if (!allow_always) break; done = 0; - if ((fp = fopen(CertificateFile, "a"))) + fp = fopen(CertificateFile, "a"); + if (fp) { if (PEM_write_X509(fp, cert)) done = 1; diff --git a/conn/ssl_gnutls.c b/conn/ssl_gnutls.c index fcbff0f7c..0dfb998a4 100644 --- a/conn/ssl_gnutls.c +++ b/conn/ssl_gnutls.c @@ -318,7 +318,8 @@ static int tls_check_stored_hostname(const gnutls_datum_t *cert, const char *hos regmatch_t pmatch[3]; /* try checking against names stored in stored certs file */ - if ((fp = fopen(CertificateFile, "r"))) + fp = fopen(CertificateFile, "r"); + if (fp) { if (REGCOMP(&preg, "^#H ([a-zA-Z0-9_\\.-]+) ([0-9A-F]{4}( [0-9A-F]{4}){7})[ \t]*$", @@ -829,7 +830,8 @@ static int tls_check_one_certificate(const gnutls_datum_t *certdata, break; case OP_MAX + 3: /* accept always */ done = 0; - if ((fp = fopen(CertificateFile, "a"))) + fp = fopen(CertificateFile, "a"); + if (fp) { /* save hostname if necessary */ if (certerr & CERTERR_HOSTNAME) @@ -1006,7 +1008,8 @@ static void tls_get_client_cert(struct Connection *conn) } cn += 3; - if ((cnend = strstr(dn, ",EMAIL="))) + cnend = strstr(dn, ",EMAIL="); + if (cnend) *cnend = '\0'; /* if we are using a client cert, SASL may expect an external auth name */ @@ -1172,7 +1175,8 @@ static int tls_negotiate(struct Connection *conn) gnutls_certificate_set_verify_flags(data->xcred, GNUTLS_VERIFY_DISABLE_TIME_CHECKS); #endif - if ((err = gnutls_init(&data->state, GNUTLS_CLIENT))) + err = gnutls_init(&data->state, GNUTLS_CLIENT); + if (err) { mutt_error("gnutls_handshake: %s", gnutls_strerror(err)); mutt_sleep(2); diff --git a/curs_main.c b/curs_main.c index 7a6e98efc..76d2e86e8 100644 --- a/curs_main.c +++ b/curs_main.c @@ -111,7 +111,7 @@ static const char *NoVisible = N_("No visible messages."); if (Context && menu->current >= Context->vcount) \ { \ mutt_flushinp(); \ - mutt_error(_(NoVisible)); \ + mutt_error(_(NoVisible)); \ break; \ } @@ -499,9 +499,10 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, * switch statement would need to be run. */ mutt_folder_hook(buf); - if ((Context = mx_open_mailbox( - buf, (option(OPT_READ_ONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ? MUTT_READONLY : 0, - NULL)) != NULL) + Context = mx_open_mailbox( + buf, (option(OPT_READ_ONLY) || (op == OP_MAIN_CHANGE_FOLDER_READONLY)) ? MUTT_READONLY : 0, + NULL); + if (Context) { menu->current = ci_first_message(); } diff --git a/doc/makedoc.c b/doc/makedoc.c index b2566e40a..3046df957 100644 --- a/doc/makedoc.c +++ b/doc/makedoc.c @@ -1409,7 +1409,8 @@ int main(int argc, char *argv[]) int c; FILE *f = NULL; - if ((Progname = strrchr(argv[0], '/'))) + Progname = strrchr(argv[0], '/'); + if (Progname) Progname++; else Progname = argv[0]; diff --git a/edit.c b/edit.c index 80e07c6f2..57ae237cc 100644 --- a/edit.c +++ b/edit.c @@ -114,7 +114,8 @@ static char **be_snarf_file(const char *path, char **buf, int *max, int *len, in char tmp[LONG_STRING]; struct stat sb; - if ((f = fopen(path, "r"))) + f = fopen(path, "r"); + if (f) { fstat(fileno(f), &sb); buf = be_snarf_data(f, buf, max, len, 0, sb.st_size, 0); diff --git a/enter.c b/enter.c index c7df256ae..827105d88 100644 --- a/enter.c +++ b/enter.c @@ -547,7 +547,8 @@ int mutt_enter_string_full(char *buf, size_t buflen, int col, int flags, int mul } else if (flags & MUTT_ALIAS && ch == OP_EDITOR_COMPLETE_QUERY) { - if ((i = state->curpos)) + i = state->curpos; + if (i != 0) { for (; i && state->wbuf[i - 1] != ','; i--) ; diff --git a/hdrline.c b/hdrline.c index 49fa35ffa..2caaa8b43 100644 --- a/hdrline.c +++ b/hdrline.c @@ -562,7 +562,8 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co case 'b': if (ctx) { - if ((p = strrchr(ctx->path, '/'))) + p = strrchr(ctx->path, '/'); + if (p) mutt_str_strfcpy(buf, p + 1, buflen); else mutt_str_strfcpy(buf, ctx->path, buflen); @@ -1114,7 +1115,8 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co if (hdr->env->from && hdr->env->from->mailbox) { mutt_str_strfcpy(tmp, mutt_addr_for_display(hdr->env->from), sizeof(tmp)); - if ((p = strpbrk(tmp, "%@"))) + p = strpbrk(tmp, "%@"); + if (p) *p = 0; } else @@ -1134,7 +1136,8 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co } else mutt_format_s(tmp, sizeof(tmp), prec, mutt_get_name(hdr->env->from)); - if ((p = strpbrk(tmp, " %@"))) + p = strpbrk(tmp, " %@"); + if (p) *p = 0; mutt_format_s(buf, buflen, prec, tmp); break; diff --git a/header.c b/header.c index 95dc93e2e..6fe6de40f 100644 --- a/header.c +++ b/header.c @@ -191,7 +191,8 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, path[l] = '\0'; mutt_expand_path(path, sizeof(path)); - if ((body2 = mutt_make_file_attach(path))) + body2 = mutt_make_file_attach(path); + if (body2) { body2->description = mutt_str_strdup(p); for (parts = msg->content; parts->next; parts = parts->next) diff --git a/help.c b/help.c index 7a7d31089..a459b78ec 100644 --- a/help.c +++ b/help.c @@ -57,7 +57,8 @@ static const struct Binding *help_lookup_function(int op, int menu) return (&OpGeneric[i]); } - if ((map = km_get_table(menu))) + map = km_get_table(menu); + if (map) { for (int i = 0; map[i].name; i++) if (map[i].op == op) @@ -224,7 +225,8 @@ static void format_line(FILE *f, int ismacro, const char *t1, const char *t2, co /* don't try to press string into one line with less than 40 characters. The double parenthesis avoids a gcc warning, sigh ... */ - if ((split = MuttIndexWindow->cols < 40)) + split = MuttIndexWindow->cols; + if (split < 40) { col_a = col = 0; col_b = LONG_STRING; diff --git a/hook.c b/hook.c index a34331de4..048360a85 100644 --- a/hook.c +++ b/hook.c @@ -218,9 +218,10 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, if (data & (MUTT_SENDHOOK | MUTT_SEND2HOOK | MUTT_SAVEHOOK | MUTT_FCCHOOK | MUTT_MESSAGEHOOK | MUTT_REPLYHOOK)) { - if ((pat = mutt_pattern_comp( - pattern.data, (data & (MUTT_SENDHOOK | MUTT_SEND2HOOK | MUTT_FCCHOOK)) ? 0 : MUTT_FULL_MSG, - err)) == NULL) + pat = mutt_pattern_comp( + pattern.data, + (data & (MUTT_SENDHOOK | MUTT_SEND2HOOK | MUTT_FCCHOOK)) ? 0 : MUTT_FULL_MSG, err); + if (!pat) goto error; } else if (~data & MUTT_GLOBALHOOK) /* NOT a global hook */ @@ -228,12 +229,13 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, /* Hooks not allowing full patterns: Check syntax of regex */ rx = mutt_mem_malloc(sizeof(regex_t)); #ifdef MUTT_CRYPTHOOK - if ((rc = REGCOMP(rx, NONULL(pattern.data), - ((data & (MUTT_CRYPTHOOK | MUTT_CHARSETHOOK | MUTT_ICONVHOOK)) ? REG_ICASE : 0))) != 0) + rc = REGCOMP(rx, NONULL(pattern.data), + ((data & (MUTT_CRYPTHOOK | MUTT_CHARSETHOOK | MUTT_ICONVHOOK)) ? REG_ICASE : 0)); #else - if ((rc = REGCOMP(rx, NONULL(pattern.data), - (data & (MUTT_CHARSETHOOK | MUTT_ICONVHOOK)) ? REG_ICASE : 0)) != 0) + rc = REGCOMP(rx, NONULL(pattern.data), + (data & (MUTT_CHARSETHOOK | MUTT_ICONVHOOK)) ? REG_ICASE : 0); #endif /* MUTT_CRYPTHOOK */ + if (rc != 0) { regerror(rc, rx, err->data, err->dsize); FREE(&rx); diff --git a/imap/command.c b/imap/command.c index eba868e8e..334d7adf0 100644 --- a/imap/command.c +++ b/imap/command.c @@ -376,7 +376,8 @@ static void cmd_parse_capability(struct ImapData *idata, char *s) mutt_debug(3, "Handling CAPABILITY\n"); s = imap_next_word(s); - if ((bracket = strchr(s, ']'))) + bracket = strchr(s, ']'); + if (bracket) *bracket = '\0'; FREE(&idata->capstr); idata->capstr = mutt_str_strdup(s); diff --git a/imap/imap.c b/imap/imap.c index 4958335a2..eaba75ca7 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1607,7 +1607,8 @@ int imap_status(char *path, int queue) imap_exec(idata, buf, 0); queued = 0; - if ((status = imap_mboxcache_get(idata, mbox, 0))) + status = imap_mboxcache_get(idata, mbox, 0); + if (status) return status->messages; return 0; @@ -2433,8 +2434,9 @@ int imap_sync_mailbox(struct Context *ctx, int expunge) /* if we are expunging anyway, we can do deleted messages very quickly... */ if (expunge && mutt_bit_isset(ctx->rights, MUTT_ACL_DELETE)) { - if ((rc = imap_exec_msgset(idata, "UID STORE", "+FLAGS.SILENT (\\Deleted)", - MUTT_DELETED, 1, 0)) < 0) + rc = imap_exec_msgset(idata, "UID STORE", "+FLAGS.SILENT (\\Deleted)", + MUTT_DELETED, 1, 0); + if (rc < 0) { mutt_error(_("Expunge failed")); mutt_sleep(1); diff --git a/imap/message.c b/imap/message.c index b6bf35b89..4c6881e58 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1019,7 +1019,8 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno) idata = ctx->data; h = ctx->hdrs[msgno]; - if ((msg->fp = msg_cache_get(idata, h))) + msg->fp = msg_cache_get(idata, h); + if (msg->fp) { if (HEADER_DATA(h)->parsed) return 0; diff --git a/imap/util.c b/imap/util.c index ceaafeb3e..bb782e054 100644 --- a/imap/util.c +++ b/imap/util.c @@ -445,7 +445,8 @@ int imap_parse_path(const char *path, struct ImapMbox *mx) /* walk past closing '}' */ mx->mbox = mutt_str_strdup(c + 1); - if ((c = strrchr(tmp, '@'))) + c = strrchr(tmp, '@'); + if (c) { *c = '\0'; mutt_str_strfcpy(mx->account.user, tmp, sizeof(mx->account.user)); diff --git a/init.c b/init.c index 98504998e..36075906a 100644 --- a/init.c +++ b/init.c @@ -633,7 +633,8 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, int flags) pc = tok->dptr; do { - if ((pc = strpbrk(pc, "\\`"))) + pc = strpbrk(pc, "\\`"); + if (pc) { /* skip any quoted chars */ if (*pc == '\\') @@ -698,7 +699,8 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, int flags) if (*tok->dptr == '{') { tok->dptr++; - if ((pc = strchr(tok->dptr, '}'))) + pc = strchr(tok->dptr, '}'); + if (pc) { var = mutt_str_substr_dup(tok->dptr, pc); tok->dptr = pc + 1; @@ -1600,7 +1602,8 @@ static int parse_attach_list(struct Buffer *buf, struct Buffer *s, else a->major = mutt_str_strdup(buf->data); - if ((p = strchr(a->major, '/'))) + p = strchr(a->major, '/'); + if (p) { *p = '\0'; p++; @@ -1660,7 +1663,8 @@ static int parse_unattach_list(struct Buffer *buf, struct Buffer *s, else tmp = mutt_str_strdup(buf->data); - if ((minor = strchr(tmp, '/'))) + minor = strchr(tmp, '/'); + if (minor) { *minor = '\0'; minor++; @@ -2693,7 +2697,8 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, if (myvar) { - if ((val = myvar_get(myvar))) + val = myvar_get(myvar); + if (val) { pretty_var(err->data, err->dsize, myvar, val); break; @@ -3368,7 +3373,7 @@ finish: * the user has typed so far. Allocate LONG_STRING just to be sure! */ static char UserTyped[LONG_STRING] = { 0 }; -static int NumMatched = 0; /* Number of matches for completion */ +static int NumMatched = 0; /* Number of matches for completion */ static char Completed[STRING] = { 0 }; /* completed string (command or variable) */ static const char **Matches; /* this is a lie until mutt_init runs: */ @@ -4058,11 +4063,13 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) /* on one of the systems I use, getcwd() does not return the same prefix as is listed in the passwd file */ - if ((p = getenv("HOME"))) + p = getenv("HOME"); + if (p) HomeDir = mutt_str_strdup(p); /* Get some information about the user */ - if ((pw = getpwuid(getuid()))) + pw = getpwuid(getuid()); + if (pw) { char rnbuf[STRING]; @@ -4082,7 +4089,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) fputs(_("unable to determine home directory"), stderr); exit(1); } - if ((p = getenv("USER"))) + p = getenv("USER"); + if (p) Username = mutt_str_strdup(p); else { @@ -4125,7 +4133,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) } /* some systems report the FQDN instead of just the hostname */ - if ((p = strchr(utsname.nodename, '.'))) + p = strchr(utsname.nodename, '.'); + if (p) ShortHostname = mutt_str_substr_dup(utsname.nodename, p); else ShortHostname = mutt_str_strdup(utsname.nodename); @@ -4160,7 +4169,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) #endif #ifdef USE_NNTP - if ((p = getenv("NNTPSERVER"))) + p = getenv("NNTPSERVER"); + if (p) { FREE(&NewsServer); NewsServer = mutt_str_strdup(p); @@ -4172,7 +4182,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) } #endif - if ((p = getenv("MAIL"))) + p = getenv("MAIL"); + if (p) SpoolFile = mutt_str_strdup(p); else if ((p = getenv("MAILDIR"))) SpoolFile = mutt_str_strdup(p); @@ -4186,7 +4197,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) SpoolFile = mutt_str_strdup(buffer); } - if ((p = getenv("MAILCAPS"))) + p = getenv("MAILCAPS"); + if (p) MailcapPath = mutt_str_strdup(p); else { diff --git a/keymap.c b/keymap.c index 8efee03e3..4e956b660 100644 --- a/keymap.c +++ b/keymap.c @@ -543,7 +543,8 @@ int km_dokey(int menu) { /* check generic menu */ bindings = OpGeneric; - if ((func = get_func(bindings, tmp.op))) + func = get_func(bindings, tmp.op); + if (func) return tmp.op; } @@ -619,7 +620,8 @@ static const char *km_keyname(int c) static char buf[10]; const char *p = NULL; - if ((p = mutt_map_get_name(c, KeyNames))) + p = mutt_map_get_name(c, KeyNames); + if (p) return p; if (c < 256 && c > -128 && iscntrl((unsigned char) c)) diff --git a/main.c b/main.c index 02a0d9a1f..b1cff104d 100644 --- a/main.c +++ b/main.c @@ -274,8 +274,9 @@ int main(int argc, char **argv, char **env) } /* USE_NNTP 'g:G' */ - if ((i = getopt(argc, argv, - "+A:a:Bb:F:f:c:Dd:l:Ee:g:GH:s:i:hm:npQ:RSvxyzZ")) != EOF) + i = getopt(argc, argv, "+A:a:Bb:F:f:c:Dd:l:Ee:g:GH:s:i:hm:npQ:RSvxyzZ"); + if (i != EOF) + { switch (i) { case 'A': @@ -412,6 +413,7 @@ int main(int argc, char **argv, char **env) default: usage(); } + } } /* collapse remaining argv */ @@ -482,7 +484,8 @@ int main(int argc, char **argv, char **env) struct ListNode *np; STAILQ_FOREACH(np, &alias_queries, entries) { - if ((a = mutt_lookup_alias(np->data))) + a = mutt_lookup_alias(np->data); + if (a) { /* output in machine-readable form */ mutt_addrlist_to_intl(a, NULL); @@ -918,9 +921,9 @@ int main(int argc, char **argv, char **env) mutt_folder_hook(folder); mutt_startup_shutdown_hook(MUTT_STARTUPHOOK); - if ((Context = mx_open_mailbox( - folder, ((flags & MUTT_RO) || option(OPT_READ_ONLY)) ? MUTT_READONLY : 0, NULL)) || - !explicit_folder) + Context = mx_open_mailbox( + folder, ((flags & MUTT_RO) || option(OPT_READ_ONLY)) ? MUTT_READONLY : 0, NULL); + if (Context || !explicit_folder) { #ifdef USE_SIDEBAR mutt_sb_set_open_buffy(); diff --git a/mh.c b/mh.c index e0a7d8533..89d85f6cf 100644 --- a/mh.c +++ b/mh.c @@ -149,7 +149,8 @@ static short mhs_set(struct MhSequences *mhs, int i, short f) static int mh_read_token(char *t, int *first, int *last) { char *p = NULL; - if ((p = strchr(t, '-'))) + p = strchr(t, '-'); + if (p) { *p++ = '\0'; if (mutt_str_atoi(t, first) < 0 || mutt_str_atoi(p, last) < 0) @@ -502,7 +503,8 @@ static void mh_update_sequences(struct Context *ctx) snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->path); /* first, copy unknown sequences */ - if ((ofp = fopen(sequences, "r"))) + ofp = fopen(sequences, "r"); + if (ofp) { while ((buf = mutt_file_read_line(buf, &s, ofp, &l, 0))) { @@ -524,7 +526,8 @@ static void mh_update_sequences(struct Context *ctx) if (ctx->hdrs[l]->deleted) continue; - if ((p = strrchr(ctx->hdrs[l]->path, '/'))) + p = strrchr(ctx->hdrs[l]->path, '/'); + if (p) p++; else p = ctx->hdrs[l]->path; @@ -600,7 +603,8 @@ static void mh_sequences_add_one(struct Context *ctx, int n, short unseen, snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(MhSeqFlagged)); snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->path); - if ((ofp = fopen(sequences, "r"))) + ofp = fopen(sequences, "r"); + if (ofp) { while ((buf = mutt_file_read_line(buf, &sz, ofp, &line, 0))) { @@ -650,7 +654,8 @@ static void mh_update_maildir(struct Maildir *md, struct MhSequences *mhs) for (; md; md = md->next) { - if ((p = strrchr(md->h->path, '/'))) + p = strrchr(md->h->path, '/'); + if (p) p++; else p = md->h->path; @@ -1598,7 +1603,8 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He mutt_str_strfcpy(subdir, s, 4); /* extract the flags */ - if ((s = strchr(s, ':'))) + s = strchr(s, ':'); + if (s) mutt_str_strfcpy(suffix, s, sizeof(suffix)); else suffix[0] = '\0'; @@ -1989,11 +1995,13 @@ static char *maildir_canon_filename(char *dest, const char *src, size_t l) { char *t = NULL, *u = NULL; - if ((t = strrchr(src, '/'))) + t = strrchr(src, '/'); + if (t) src = t + 1; mutt_str_strfcpy(dest, src, l); - if ((u = strrchr(dest, ':'))) + u = strrchr(dest, ':'); + if (u) *u = '\0'; return dest; @@ -2270,8 +2278,8 @@ static int mh_check_mailbox(struct Context *ctx, int *index_hint) { ctx->hdrs[i]->active = false; - if ((p = mutt_hash_find(fnames, ctx->hdrs[i]->path)) && p->h && - (mbox_strict_cmp_headers(ctx->hdrs[i], p->h))) + p = mutt_hash_find(fnames, ctx->hdrs[i]->path); + if (p && p->h && mbox_strict_cmp_headers(ctx->hdrs[i], p->h)) { ctx->hdrs[i]->active = true; /* found the right message */ @@ -2480,8 +2488,8 @@ FILE *maildir_open_find_message(const char *folder, const char *msg, char **newn maildir_canon_filename(unique, msg, sizeof(unique)); - if ((fp = md_open_find_message(folder, unique, new_hits > cur_hits ? "new" : "cur", newname)) || - errno != ENOENT) + fp = md_open_find_message(folder, unique, new_hits > cur_hits ? "new" : "cur", newname); + if (fp || (errno != ENOENT)) { if (new_hits < UINT_MAX && cur_hits < UINT_MAX) { @@ -2491,8 +2499,8 @@ FILE *maildir_open_find_message(const char *folder, const char *msg, char **newn return fp; } - if ((fp = md_open_find_message(folder, unique, new_hits > cur_hits ? "cur" : "new", newname)) || - errno != ENOENT) + fp = md_open_find_message(folder, unique, new_hits > cur_hits ? "cur" : "new", newname); + if (fp || (errno != ENOENT)) { if (new_hits < UINT_MAX && cur_hits < UINT_MAX) { diff --git a/mutt/charset.c b/mutt/charset.c index 424cdb669..ecc390fbd 100644 --- a/mutt/charset.c +++ b/mutt/charset.c @@ -345,7 +345,8 @@ void mutt_cs_canonical_charset(char *dest, size_t dlen, const char *name) char in[LONG_STRING], scratch[LONG_STRING]; mutt_str_strfcpy(in, name, sizeof(in)); - if ((ext = strchr(in, '/'))) + ext = strchr(in, '/'); + if (ext) *ext++ = '\0'; if ((mutt_str_strcasecmp(in, "utf-8") == 0) || diff --git a/mutt/date.c b/mutt/date.c index b347cd6ab..6f456244b 100644 --- a/mutt/date.c +++ b/mutt/date.c @@ -151,7 +151,8 @@ static time_t compute_tz(time_t g, struct tm *utc) t = (((lt->tm_hour - utc->tm_hour) * 60) + (lt->tm_min - utc->tm_min)) * 60; - if ((yday = (lt->tm_yday - utc->tm_yday))) + yday = (lt->tm_yday - utc->tm_yday); + if (yday != 0) { /* This code is optimized to negative timezones (West of Greenwich) */ if ((yday == -1) || /* UTC passed midnight before localtime */ @@ -478,7 +479,8 @@ time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) mutt_str_strfcpy(scratch, s, sizeof(scratch)); /* kill the day of the week, if it exists. */ - if ((t = strchr(scratch, ','))) + t = strchr(scratch, ','); + if (t) t++; else t = scratch; diff --git a/muttlib.c b/muttlib.c index 4ac366528..d5b9287a3 100644 --- a/muttlib.c +++ b/muttlib.c @@ -195,10 +195,12 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) else { struct passwd *pw = NULL; - if ((t = strchr(s + 1, '/'))) + t = strchr(s + 1, '/'); + if (t) *t = 0; - if ((pw = getpwnam(s + 1))) + pw = getpwnam(s + 1); + if (pw) { mutt_str_strfcpy(p, pw->pw_dir, sizeof(p)); if (t) @@ -254,7 +256,8 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) struct Header *h = NULL; struct Address *alias = NULL; - if ((alias = mutt_lookup_alias(s + 1))) + alias = mutt_lookup_alias(s + 1); + if (alias) { h = mutt_new_header(); h->env = mutt_env_new(); @@ -765,7 +768,8 @@ void mutt_save_path(char *d, size_t dsize, struct Address *a) { char *p = NULL; - if ((p = strpbrk(d, "%@"))) + p = strpbrk(d, "%@"); + if (p) *p = 0; } mutt_str_strlower(d); @@ -1265,7 +1269,7 @@ void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const c col++; } } - if (len + wlen > buflen) + if ((len + wlen) > buflen) len = mutt_wstr_trunc(tmp, buflen - wlen, cols - col, NULL); memcpy(wptr, tmp, len); wptr += len; @@ -1330,7 +1334,8 @@ void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const c *p = '_'; } - if ((len = mutt_str_strlen(tmp)) + wlen > buflen) + len = mutt_str_strlen(tmp); + if ((len + wlen) > buflen) len = mutt_wstr_trunc(tmp, buflen - wlen, cols - col, NULL); memcpy(wptr, tmp, len); diff --git a/mx.c b/mx.c index f84808ade..6554161f8 100644 --- a/mx.c +++ b/mx.c @@ -701,7 +701,8 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint) { char *p = NULL; - if ((p = mutt_find_hook(MUTT_MBOXHOOK, ctx->path))) + p = mutt_find_hook(MUTT_MBOXHOOK, ctx->path); + if (p) { is_spool = 1; mutt_str_strfcpy(mbox, p, sizeof(mbox)); diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index fd134f8aa..804397677 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -447,13 +447,13 @@ int mutt_is_application_pgp(struct Body *m) if ((mutt_str_strcasecmp(m->subtype, "pgp") == 0) || (mutt_str_strcasecmp(m->subtype, "x-pgp-message") == 0)) { - if ((p = mutt_param_get("x-action", m->parameter)) && - ((mutt_str_strcasecmp(p, "sign") == 0) || - (mutt_str_strcasecmp(p, "signclear") == 0))) + p = mutt_param_get("x-action", m->parameter); + if (p && ((mutt_str_strcasecmp(p, "sign") == 0) || + (mutt_str_strcasecmp(p, "signclear") == 0))) t |= PGPSIGN; - if ((p = mutt_param_get("format", m->parameter)) && - (mutt_str_strcasecmp(p, "keys-only") == 0)) + p = mutt_param_get("format", m->parameter); + if (p && (mutt_str_strcasecmp(p, "keys-only") == 0)) { t |= PGPKEY; } @@ -501,7 +501,8 @@ int mutt_is_application_smime(struct Body *m) if ((mutt_str_strcasecmp(m->subtype, "x-pkcs7-mime") == 0) || (mutt_str_strcasecmp(m->subtype, "pkcs7-mime") == 0)) { - if ((t = mutt_param_get("smime-type", m->parameter))) + t = mutt_param_get("smime-type", m->parameter); + if (t) { if (mutt_str_strcasecmp(t, "enveloped-data") == 0) return SMIMEENCRYPT; diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index d1cb04d58..da9d01277 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -2227,7 +2227,8 @@ static int pgp_gpgme_extract_keys(gpgme_data_t keydata, FILE **fp, int dryrun) err = gpgme_op_keylist_start(tmpctx, NULL, 0); while (!err) { - if ((err = gpgme_op_keylist_next(tmpctx, &key))) + err = gpgme_op_keylist_next(tmpctx, &key); + if (err) break; uid = key->uids; subkey = key->subkeys; @@ -2370,7 +2371,8 @@ int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, int just_one) rc = (pgp_gpgme_check_traditional(fp, b->parts, 0) || rc); else if (b->type == TYPETEXT) { - if ((r = mutt_is_application_pgp(b))) + r = mutt_is_application_pgp(b); + if (r != 0) rc = (rc || r); else rc = (pgp_check_traditional_one_body(fp, b) || rc); @@ -3161,7 +3163,8 @@ static int compare_key_address(const void *a, const void *b) struct CryptKeyInfo **t = (struct CryptKeyInfo **) b; int r; - if ((r = mutt_str_strcasecmp((*s)->uid, (*t)->uid))) + r = mutt_str_strcasecmp((*s)->uid, (*t)->uid); + if (r != 0) return r > 0; else return (mutt_str_strcasecmp(crypt_fpr_or_lkeyid(*s), crypt_fpr_or_lkeyid(*t)) > 0); @@ -3182,7 +3185,8 @@ static int compare_keyid(const void *a, const void *b) struct CryptKeyInfo **t = (struct CryptKeyInfo **) b; int r; - if ((r = mutt_str_strcasecmp(crypt_fpr_or_lkeyid(*s), crypt_fpr_or_lkeyid(*t)))) + r = mutt_str_strcasecmp(crypt_fpr_or_lkeyid(*s), crypt_fpr_or_lkeyid(*t)); + if (r != 0) return r > 0; else return (mutt_str_strcasecmp((*s)->uid, (*t)->uid) > 0); @@ -3233,12 +3237,14 @@ static int compare_key_trust(const void *a, const void *b) unsigned long ts = 0, tt = 0; int r; - if ((r = (((*s)->flags & (KEYFLAG_RESTRICTIONS)) - ((*t)->flags & (KEYFLAG_RESTRICTIONS))))) + r = (((*s)->flags & (KEYFLAG_RESTRICTIONS)) - ((*t)->flags & (KEYFLAG_RESTRICTIONS))); + if (r != 0) return r > 0; ts = (*s)->validity; tt = (*t)->validity; - if ((r = (tt - ts))) + r = (tt - ts); + if (r != 0) return r < 0; if ((*s)->kobj->subkeys) @@ -3257,7 +3263,8 @@ static int compare_key_trust(const void *a, const void *b) if (ts < tt) return 0; - if ((r = mutt_str_strcasecmp((*s)->uid, (*t)->uid))) + r = mutt_str_strcasecmp((*s)->uid, (*t)->uid); + if (r != 0) return r > 0; return (mutt_str_strcasecmp(crypt_fpr_or_lkeyid((*s)), crypt_fpr_or_lkeyid((*t))) > 0); } @@ -3541,23 +3548,38 @@ static unsigned int key_check_cap(gpgme_key_t key, enum KeyCap cap) case KEY_CAP_CAN_ENCRYPT: ret = key->can_encrypt; if (ret == 0) + { for (subkey = key->subkeys; subkey; subkey = subkey->next) - if ((ret = subkey->can_encrypt)) + { + ret = subkey->can_encrypt; + if (ret != 0) break; + } + } break; case KEY_CAP_CAN_SIGN: ret = key->can_sign; if (ret == 0) + { for (subkey = key->subkeys; subkey; subkey = subkey->next) - if ((ret = subkey->can_sign)) + { + ret = subkey->can_sign; + if (ret != 0) break; + } + } break; case KEY_CAP_CAN_CERTIFY: ret = key->can_certify; if (ret == 0) + { for (subkey = key->subkeys; subkey; subkey = subkey->next) - if ((ret = subkey->can_certify)) + { + ret = subkey->can_certify; + if (ret != 0) break; + } + } break; } @@ -4600,7 +4622,8 @@ static struct CryptKeyInfo *crypt_ask_for_key(char *tag, char *whatfor, short ab } } - if ((key = crypt_getkeybystr(resp, abilities, app, forced_valid))) + key = crypt_getkeybystr(resp, abilities, app, forced_valid); + if (key) return key; mutt_error(_("No matching keys found for \"%s\""), resp); @@ -4970,8 +4993,9 @@ static int gpgme_send_menu(struct Header *msg, int is_smime) break; case 'a': /* sign (a)s */ - if ((p = crypt_ask_for_key(_("Sign as: "), NULL, KEYFLAG_CANSIGN, - is_smime ? APPLICATION_SMIME : APPLICATION_PGP, NULL))) + p = crypt_ask_for_key(_("Sign as: "), NULL, KEYFLAG_CANSIGN, + is_smime ? APPLICATION_SMIME : APPLICATION_PGP, NULL); + if (p) { snprintf(input_signas, sizeof(input_signas), "0x%s", crypt_fpr_or_lkeyid(p)); mutt_str_replace(is_smime ? &SmimeDefaultKey : &PgpSignAs, input_signas); diff --git a/ncrypt/gnupgparse.c b/ncrypt/gnupgparse.c index c18e1626e..624723a8a 100644 --- a/ncrypt/gnupgparse.c +++ b/ncrypt/gnupgparse.c @@ -147,7 +147,8 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe for (p = buf; p; p = pend) { - if ((pend = strchr(p, ':'))) + pend = strchr(p, ':'); + if (pend) *pend++ = 0; field++; if (!*p && (field != 1) && (field != 10)) diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 609c23ea4..7d2badf75 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -110,7 +110,8 @@ bool pgp_use_gpg_agent(void) if (!option(OPT_PGP_USE_GPG_AGENT)) return false; - if ((tty = ttyname(0))) + tty = ttyname(0); + if (tty) { setenv("GPG_TTY", tty, 0); mutt_envlist_set("GPG_TTY", tty, false); @@ -443,8 +444,9 @@ int pgp_application_pgp_handler(struct Body *m, struct State *s) return -1; } - if ((thepid = pgp_invoke_decode(&pgpin, NULL, &pgperr, -1, fileno(pgpout), - -1, tmpfname, needpass)) == -1) + thepid = pgp_invoke_decode(&pgpin, NULL, &pgperr, -1, fileno(pgpout), + -1, tmpfname, needpass); + if (thepid == -1) { mutt_file_fclose(&pgpout); maybe_goodsig = false; @@ -689,7 +691,8 @@ int pgp_check_traditional(FILE *fp, struct Body *b, int just_one) rc = pgp_check_traditional(fp, b->parts, 0) || rc; else if (b->type == TYPETEXT) { - if ((r = mutt_is_application_pgp(b))) + r = mutt_is_application_pgp(b); + if (r) rc = rc || r; else rc = pgp_check_traditional_one_body(fp, b) || rc; @@ -734,8 +737,8 @@ int pgp_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile) crypt_current_time(s, "PGP"); - if ((thepid = pgp_invoke_verify(NULL, &pgpout, NULL, -1, -1, fileno(pgperr), - tempfile, sigfile)) != -1) + thepid = pgp_invoke_verify(NULL, &pgpout, NULL, -1, -1, fileno(pgperr), tempfile, sigfile); + if (thepid != -1) { if (pgp_copy_checksig(pgpout, s->fpout) >= 0) badsig = 0; @@ -747,7 +750,8 @@ int pgp_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile) if (pgp_copy_checksig(pgperr, s->fpout) >= 0) badsig = 0; - if ((rv = mutt_wait_filter(thepid))) + rv = mutt_wait_filter(thepid); + if (rv) badsig = -1; mutt_debug(1, "mutt_wait_filter returned %d.\n", rv); @@ -862,8 +866,8 @@ static struct Body *pgp_decrypt_part(struct Body *a, struct State *s, mutt_file_copy_bytes(s->fpin, pgptmp, a->length); mutt_file_fclose(&pgptmp); - if ((thepid = pgp_invoke_decrypt(&pgpin, &pgpout, NULL, -1, -1, - fileno(pgperr), pgptmpfile)) == -1) + thepid = pgp_invoke_decrypt(&pgpin, &pgpout, NULL, -1, -1, fileno(pgperr), pgptmpfile); + if (thepid == -1) { mutt_file_fclose(&pgperr); unlink(pgptmpfile); @@ -1406,8 +1410,9 @@ struct Body *pgp_encrypt_message(struct Body *a, char *keylist, int sign) mutt_write_mime_body(a, fptmp); mutt_file_fclose(&fptmp); - if ((thepid = pgp_invoke_encrypt(&pgpin, NULL, NULL, -1, fileno(fpout), - fileno(pgperr), pgpinfile, keylist, sign)) == -1) + thepid = pgp_invoke_encrypt(&pgpin, NULL, NULL, -1, fileno(fpout), + fileno(pgperr), pgpinfile, keylist, sign); + if (thepid == -1) { mutt_file_fclose(&fpout); mutt_file_fclose(&pgperr); @@ -1581,8 +1586,9 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis unlink(pgperrfile); - if ((thepid = pgp_invoke_traditional(&pgpin, NULL, NULL, -1, fileno(pgpout), - fileno(pgperr), pgpinfile, keylist, flags)) == -1) + thepid = pgp_invoke_traditional(&pgpin, NULL, NULL, -1, fileno(pgpout), + fileno(pgperr), pgpinfile, keylist, flags); + if (thepid == -1) { mutt_perror(_("Can't invoke PGP")); mutt_file_fclose(&pgpout); @@ -1803,7 +1809,8 @@ int pgp_send_menu(struct Header *msg) case 'a': /* sign (a)s */ unset_option(OPT_PGP_CHECK_TRUST); - if ((p = pgp_ask_for_key(_("Sign as: "), NULL, 0, PGP_SECRING))) + p = pgp_ask_for_key(_("Sign as: "), NULL, 0, PGP_SECRING); + if (p) { snprintf(input_signas, sizeof(input_signas), "0x%s", pgp_fpr_or_lkeyid(p)); mutt_str_replace(&PgpSignAs, input_signas); diff --git a/ncrypt/pgpkey.c b/ncrypt/pgpkey.c index 89510f598..00eab239c 100644 --- a/ncrypt/pgpkey.c +++ b/ncrypt/pgpkey.c @@ -320,7 +320,8 @@ static int compare_key_address(const void *a, const void *b) struct PgpUid **s = (struct PgpUid **) a; struct PgpUid **t = (struct PgpUid **) b; - if ((r = mutt_str_strcasecmp((*s)->addr, (*t)->addr))) + r = mutt_str_strcasecmp((*s)->addr, (*t)->addr); + if (r != 0) return r > 0; else return (mutt_str_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), @@ -340,8 +341,8 @@ static int compare_keyid(const void *a, const void *b) struct PgpUid **s = (struct PgpUid **) a; struct PgpUid **t = (struct PgpUid **) b; - if ((r = mutt_str_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), - pgp_fpr_or_lkeyid((*t)->parent)))) + r = mutt_str_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), pgp_fpr_or_lkeyid((*t)->parent)); + if (r != 0) return r > 0; else return (mutt_str_strcasecmp((*s)->addr, (*t)->addr) > 0); @@ -358,8 +359,9 @@ static int compare_key_date(const void *a, const void *b) struct PgpUid **s = (struct PgpUid **) a; struct PgpUid **t = (struct PgpUid **) b; - if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) - return r > 0; + r = ((*s)->parent->gen_time - (*t)->parent->gen_time); + if (r != 0) + return (r > 0); return (mutt_str_strcasecmp((*s)->addr, (*t)->addr) > 0); } @@ -375,17 +377,22 @@ static int compare_key_trust(const void *a, const void *b) struct PgpUid **s = (struct PgpUid **) a; struct PgpUid **t = (struct PgpUid **) b; - if ((r = (((*s)->parent->flags & (KEYFLAG_RESTRICTIONS)) - - ((*t)->parent->flags & (KEYFLAG_RESTRICTIONS))))) - return r > 0; - if ((r = ((*s)->trust - (*t)->trust))) - return r < 0; - if ((r = ((*s)->parent->keylen - (*t)->parent->keylen))) - return r < 0; - if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) - return r < 0; - if ((r = mutt_str_strcasecmp((*s)->addr, (*t)->addr))) - return r > 0; + r = (((*s)->parent->flags & (KEYFLAG_RESTRICTIONS)) - + ((*t)->parent->flags & (KEYFLAG_RESTRICTIONS))); + if (r != 0) + return (r > 0); + r = ((*s)->trust - (*t)->trust); + if (r != 0) + return (r < 0); + r = ((*s)->parent->keylen - (*t)->parent->keylen); + if (r != 0) + return (r < 0); + r = ((*s)->parent->gen_time - (*t)->parent->gen_time); + if (r != 0) + return (r < 0); + r = mutt_str_strcasecmp((*s)->addr, (*t)->addr); + if (r != 0) + return (r > 0); return (mutt_str_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), pgp_fpr_or_lkeyid((*t)->parent)) > 0); } @@ -579,8 +586,9 @@ static struct PgpKeyInfo *pgp_select_key(struct PgpKeyInfo *keys, snprintf(tmpbuf, sizeof(tmpbuf), "0x%s", pgp_fpr_or_lkeyid(pgp_principal_key(KeyTable[menu->current]->parent))); - if ((thepid = pgp_invoke_verify_key(NULL, NULL, NULL, -1, fileno(fp), - fileno(devnull), tmpbuf)) == -1) + thepid = pgp_invoke_verify_key(NULL, NULL, NULL, -1, fileno(fp), + fileno(devnull), tmpbuf); + if (thepid == -1) { mutt_perror(_("Can't create filter")); unlink(tempfile); @@ -707,7 +715,8 @@ struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, en } } - if ((key = pgp_getkeybystr(resp, abilities, keyring))) + key = pgp_getkeybystr(resp, abilities, keyring); + if (key) return key; mutt_error(_("No matching keys found for \"%s\""), resp); @@ -764,8 +773,8 @@ struct Body *pgp_make_key_attachment(char *tempf) mutt_message(_("Invoking PGP...")); - if ((thepid = pgp_invoke_export(NULL, NULL, NULL, -1, fileno(tempfp), - fileno(devnull), tmp)) == -1) + thepid = pgp_invoke_export(NULL, NULL, NULL, -1, fileno(tempfp), fileno(devnull), tmp); + if (thepid == -1) { mutt_perror(_("Can't create filter")); unlink(tempf); @@ -938,7 +947,8 @@ struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, short abilities, /* * Else: Ask the user. */ - if ((k = pgp_select_key(matches, a, NULL))) + k = pgp_select_key(matches, a, NULL); + if (k) pgp_remove_key(&matches, k); } @@ -1025,7 +1035,8 @@ struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, enum PgpRing keyrin if (matches) { - if ((k = pgp_select_key(matches, NULL, p))) + k = pgp_select_key(matches, NULL, p); + if (k) pgp_remove_key(&matches, k); pgp_free_key(&matches); diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 014acb7dc..fba62f893 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -756,7 +756,8 @@ static struct SmimeKey *smime_ask_for_key(char *prompt, short abilities, short p if (mutt_get_field(prompt, resp, sizeof(resp), MUTT_CLEAR) != 0) return NULL; - if ((key = smime_get_key_by_str(resp, abilities, public))) + key = smime_get_key_by_str(resp, abilities, public); + if (key) return key; mutt_error(_("No matching keys found for \"%s\""), resp); @@ -938,9 +939,9 @@ static int smime_handle_cert_email(char *certificate, char *mailbox, int copy, } mutt_file_unlink(tmpfname); - if ((thepid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), - certificate, NULL, NULL, NULL, NULL, NULL, NULL, - SmimeGetCertEmailCommand)) == -1) + thepid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), certificate, + NULL, NULL, NULL, NULL, NULL, NULL, SmimeGetCertEmailCommand); + if (thepid == -1) { mutt_message(_("Error: unable to create OpenSSL subprocess!")); mutt_file_fclose(&fperr); @@ -1034,8 +1035,9 @@ static char *smime_extract_certificate(char *infile) /* Step 1: Convert the signature to a PKCS#7 structure, as we can't extract the full set of certificates directly. */ - if ((thepid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), infile, NULL, - NULL, NULL, NULL, NULL, NULL, SmimePk7outCommand)) == -1) + thepid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), infile, + NULL, NULL, NULL, NULL, NULL, NULL, SmimePk7outCommand); + if (thepid == -1) { mutt_any_key_to_continue(_("Error: unable to create OpenSSL subprocess!")); mutt_file_fclose(&fperr); @@ -1074,8 +1076,9 @@ static char *smime_extract_certificate(char *infile) /* Step 2: Extract the certificates from a PKCS#7 structure. */ - if ((thepid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), pk7out, NULL, - NULL, NULL, NULL, NULL, NULL, SmimeGetCertCommand)) == -1) + thepid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), pk7out, + NULL, NULL, NULL, NULL, NULL, NULL, SmimeGetCertCommand); + if (thepid == -1) { mutt_any_key_to_continue(_("Error: unable to create OpenSSL subprocess!")); mutt_file_fclose(&fperr); @@ -1137,8 +1140,9 @@ static char *smime_extract_signer_certificate(char *infile) /* Extract signer's certificate */ - if ((thepid = smime_invoke(NULL, NULL, NULL, -1, -1, fileno(fperr), infile, NULL, NULL, NULL, - NULL, certfile, NULL, SmimeGetSignerCertCommand)) == -1) + thepid = smime_invoke(NULL, NULL, NULL, -1, -1, fileno(fperr), infile, NULL, NULL, + NULL, NULL, certfile, NULL, SmimeGetSignerCertCommand); + if (thepid == -1) { mutt_any_key_to_continue(_("Error: unable to create OpenSSL subprocess!")); mutt_file_fclose(&fperr); @@ -1213,13 +1217,14 @@ void smime_invoke_import(char *infile, char *mailbox) } mutt_endwin(NULL); - if ((certfile = smime_extract_certificate(infile))) + certfile = smime_extract_certificate(infile); + if (certfile) { mutt_endwin(NULL); - if ((thepid = smime_invoke(&smimein, NULL, NULL, -1, fileno(fpout), - fileno(fperr), certfile, NULL, NULL, NULL, NULL, - NULL, NULL, SmimeImportCertCommand)) == -1) + thepid = smime_invoke(&smimein, NULL, NULL, -1, fileno(fpout), fileno(fperr), certfile, + NULL, NULL, NULL, NULL, NULL, NULL, SmimeImportCertCommand); + if (thepid == -1) { mutt_message(_("Error: unable to create OpenSSL subprocess!")); return; @@ -1282,7 +1287,8 @@ int smime_verify_sender(struct Header *h) if (mbox) { - if ((certfile = smime_extract_signer_certificate(tempfname))) + certfile = smime_extract_signer_certificate(tempfname); + if (certfile) { mutt_file_unlink(tempfname); if (smime_handle_cert_email(certfile, mbox, 0, NULL, NULL)) @@ -1370,7 +1376,8 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist) *certfile = '\0'; for (cert_start = certlist; cert_start; cert_start = cert_end) { - if ((cert_end = strchr(cert_start, ' '))) + cert_end = strchr(cert_start, ' '); + if (cert_end) *cert_end = '\0'; if (*cert_start) { @@ -1388,8 +1395,9 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist) mutt_write_mime_body(a, fptmp); mutt_file_fclose(&fptmp); - if ((thepid = smime_invoke_encrypt(&smimein, NULL, NULL, -1, fileno(fpout), - fileno(smimeerr), smimeinfile, certfile)) == -1) + thepid = smime_invoke_encrypt(&smimein, NULL, NULL, -1, fileno(fpout), + fileno(smimeerr), smimeinfile, certfile); + if (thepid == -1) { mutt_file_fclose(&smimeerr); mutt_file_unlink(smimeinfile); @@ -1538,8 +1546,8 @@ struct Body *smime_sign_message(struct Body *a) smime_free_key(&default_key); - if ((thepid = smime_invoke_sign(&smimein, NULL, &smimeerr, -1, - fileno(smimeout), -1, filetosign)) == -1) + thepid = smime_invoke_sign(&smimein, NULL, &smimeerr, -1, fileno(smimeout), -1, filetosign); + if (thepid == -1) { mutt_perror(_("Can't open OpenSSL subprocess!")); mutt_file_fclose(&smimeout); @@ -1696,8 +1704,9 @@ int smime_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile) crypt_current_time(s, "OpenSSL"); - if ((thepid = smime_invoke_verify(NULL, &smimeout, NULL, -1, -1, fileno(smimeerr), - tempfile, signedfile, 0)) != -1) + thepid = smime_invoke_verify(NULL, &smimeout, NULL, -1, -1, fileno(smimeerr), + tempfile, signedfile, 0); + if (thepid != -1) { fflush(smimeout); mutt_file_fclose(&smimeout); @@ -2157,7 +2166,8 @@ int smime_send_menu(struct Header *msg) case 'S': /* (s)ign in oppenc mode */ if (!SmimeDefaultKey) { - if ((key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, 0))) + key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, 0); + if (key) { mutt_str_replace(&SmimeDefaultKey, key->hash); smime_free_key(&key); @@ -2172,7 +2182,8 @@ int smime_send_menu(struct Header *msg) case 'a': /* sign (a)s */ - if ((key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, 0))) + key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, 0); + if (key) { mutt_str_replace(&SmimeDefaultKey, key->hash); smime_free_key(&key); diff --git a/pager.c b/pager.c index b75172347..ff85565f0 100644 --- a/pager.c +++ b/pager.c @@ -1545,8 +1545,8 @@ static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info, goto out; /* fake display */ } - if ((b_read = fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, - &buflen, &buf_ready)) < 0) + b_read = fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready); + if (b_read < 0) { if (change_last) (*last)--; @@ -1807,10 +1807,12 @@ static void pager_menu_redraw(struct Menu *pager_menu) #if defined(USE_SLANG_CURSES) || defined(HAVE_RESIZETERM) if (Resize) { - if ((rd->search_compiled = Resize->search_compiled)) + rd->search_compiled = Resize->search_compiled; + if (rd->search_compiled) { - if ((err = REGCOMP(&rd->search_re, rd->searchbuf, - REG_NEWLINE | mutt_which_case(rd->searchbuf))) != 0) + err = REGCOMP(&rd->search_re, rd->searchbuf, + REG_NEWLINE | mutt_which_case(rd->searchbuf)); + if (err != 0) { regerror(err, &rd->search_re, buffer, sizeof(buffer)); mutt_error("%s", buffer); @@ -2499,8 +2501,8 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e } } - if ((err = REGCOMP(&rd.search_re, searchbuf, - REG_NEWLINE | mutt_which_case(searchbuf))) != 0) + err = REGCOMP(&rd.search_re, searchbuf, REG_NEWLINE | mutt_which_case(searchbuf)); + if (err != 0) { regerror(err, &rd.search_re, buffer, sizeof(buffer)); mutt_error("%s", buffer); diff --git a/parse.c b/parse.c index 0b28d37f2..56da6e91e 100644 --- a/parse.c +++ b/parse.c @@ -325,18 +325,21 @@ void mutt_parse_content_type(char *s, struct Body *ct) /* Some pre-RFC1521 gateways still use the "name=filename" convention, * but if a filename has already been set in the content-disposition, * let that take precedence, and don't set it here */ - if ((pc = mutt_param_get("name", ct->parameter)) && !ct->filename) + pc = mutt_param_get("name", ct->parameter); + if (pc && !ct->filename) ct->filename = mutt_str_strdup(pc); #ifdef SUN_ATTACHMENT /* this is deep and utter perversion */ - if ((pc = mutt_param_get("conversions", ct->parameter))) + pc = mutt_param_get("conversions", ct->parameter); + if (pc) ct->encoding = mutt_check_encoding(pc); #endif } /* Now get the subtype */ - if ((subtype = strchr(s, '/'))) + subtype = strchr(s, '/'); + if (subtype) { *subtype++ = '\0'; for (pc = subtype; *pc && !ISSPACE(*pc) && *pc != ';'; pc++) @@ -410,9 +413,11 @@ static void parse_content_disposition(const char *s, struct Body *ct) if (s) { s = mutt_str_skip_email_wsp(s + 1); - if ((s = mutt_param_get("filename", (parms = parse_parameters(s))))) + s = mutt_param_get("filename", (parms = parse_parameters(s))); + if (s) mutt_str_replace(&ct->filename, s); - if ((s = mutt_param_get("name", parms))) + s = mutt_param_get("name", parms); + if (s) ct->form_name = mutt_str_strdup(s); mutt_param_free(&parms); } @@ -439,7 +444,8 @@ struct Body *mutt_read_mime_header(FILE *fp, int digest) while (*(line = mutt_read_rfc822_line(fp, line, &linelen)) != 0) { /* Find the value of the current header */ - if ((c = strchr(line, ':'))) + c = strchr(line, ':'); + if (c) { *c = 0; c = mutt_str_skip_email_wsp(c + 1); @@ -745,7 +751,8 @@ void mutt_parse_mime_message(struct Context *ctx, struct Header *cur) if (cur->content->parts) break; /* The message was parsed earlier. */ - if ((msg = mx_open_message(ctx, cur->msgno))) + msg = mx_open_message(ctx, cur->msgno); + if (msg) { mutt_parse_part(msg->fp, cur->content); diff --git a/pattern.c b/pattern.c index bce00f13b..bfe145cf9 100644 --- a/pattern.c +++ b/pattern.c @@ -2147,8 +2147,9 @@ int mutt_search_command(int cur, int op) { /* remember that we've already searched this message */ h->searched = true; - if ((h->matched = (mutt_pattern_exec(SearchPattern, MUTT_MATCH_FULL_ADDRESS, - Context, h, NULL) > 0))) + h->matched = + mutt_pattern_exec(SearchPattern, MUTT_MATCH_FULL_ADDRESS, Context, h, NULL); + if (h->matched > 0) { mutt_clear_error(); if (msg && *msg) diff --git a/pgppubring.c b/pgppubring.c index 93e1c02cf..3f66ea859 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -896,7 +896,8 @@ int main(int argc, char *const argv[]) mutt_str_strfcpy(kring, tmp_kring, sizeof(kring)); else { - if ((env_pgppath = getenv("PGPPATH"))) + env_pgppath = getenv("PGPPATH"); + if (env_pgppath) mutt_str_strfcpy(pgppath, env_pgppath, sizeof(pgppath)); else if ((env_home = getenv("HOME"))) snprintf(pgppath, sizeof(pgppath), "%s/.pgp", env_home); diff --git a/pop.c b/pop.c index 6ba4fb09b..e72f597b1 100644 --- a/pop.c +++ b/pop.c @@ -327,7 +327,8 @@ static int pop_fetch_headers(struct Context *ctx) if (!ctx->quiet) mutt_progress_update(&progress, i + 1 - old_count, -1); #ifdef USE_HCACHE - if ((data = mutt_hcache_fetch(hc, ctx->hdrs[i]->data, strlen(ctx->hdrs[i]->data)))) + data = mutt_hcache_fetch(hc, ctx->hdrs[i]->data, strlen(ctx->hdrs[i]->data)); + if (data) { char *uidl = mutt_str_strdup(ctx->hdrs[i]->data); int refno = ctx->hdrs[i]->refno; @@ -557,7 +558,8 @@ static int pop_fetch_message(struct Context *ctx, struct Message *msg, int msgno unsigned short bcache = 1; /* see if we already have the message in body cache */ - if ((msg->fp = mutt_bcache_get(pop_data->bcache, h->data))) + msg->fp = mutt_bcache_get(pop_data->bcache, h->data); + if (msg->fp) return 0; /* diff --git a/query.c b/query.c index d96647834..674d9ff0b 100644 --- a/query.c +++ b/query.c @@ -135,11 +135,13 @@ static struct Query *run_query(char *s, int quiet) if (!quiet) mutt_message(_("Waiting for response...")); fgets(msg, sizeof(msg), fp); - if ((p = strrchr(msg, '\n'))) + p = strrchr(msg, '\n'); + if (p) *p = '\0'; while ((buf = mutt_file_read_line(buf, &buflen, fp, &dummy, 0)) != NULL) { - if ((p = strtok(buf, "\t\n"))) + p = strtok(buf, "\t\n"); + if (p) { if (!first) { diff --git a/recvattach.c b/recvattach.c index 9daa9b009..3c5ab6041 100644 --- a/recvattach.c +++ b/recvattach.c @@ -514,8 +514,8 @@ static int query_save_attachment(FILE *fp, struct Body *body, } else { - if ((rc = mutt_check_overwrite(body->filename, buf, tfile, sizeof(tfile), - &append, directory)) == -1) + rc = mutt_check_overwrite(body->filename, buf, tfile, sizeof(tfile), &append, directory); + if (rc == -1) return -1; else if (rc == 1) { diff --git a/recvcmd.c b/recvcmd.c index 372cc0bc6..22600119b 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -467,9 +467,10 @@ static void attach_forward_bodies(FILE *fp, struct Header *hdr, struct AttachCtx if (!mime_fwd_all && !cur && (nattach > 1) && !check_can_decode(actx, cur)) { - if ((rc = query_quadoption(OPT_MIME_FORWARD_REST, - _("Can't decode all tagged attachments. " - "MIME-forward the others?"))) == MUTT_ABORT) + rc = query_quadoption( + OPT_MIME_FORWARD_REST, + _("Can't decode all tagged attachments. MIME-forward the others?")); + if (rc == MUTT_ABORT) goto bail; else if (rc == MUTT_NO) mime_fwd_any = false; @@ -590,8 +591,8 @@ static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx, struct Body *c tmpbody[0] = '\0'; - if ((rc = query_quadoption(OPT_MIME_FORWARD, - _("Forward MIME encapsulated?"))) == MUTT_NO) + rc = query_quadoption(OPT_MIME_FORWARD, _("Forward MIME encapsulated?")); + if (rc == MUTT_NO) { /* no MIME encapsulation */ @@ -844,9 +845,10 @@ void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx, if (nattach > 1 && !check_can_decode(actx, cur)) { - if ((rc = query_quadoption(OPT_MIME_FORWARD_REST, - _("Can't decode all tagged attachments. " - "MIME-encapsulate the others?"))) == MUTT_ABORT) + rc = query_quadoption(OPT_MIME_FORWARD_REST, + _("Can't decode all tagged attachments. " + "MIME-encapsulate the others?")); + if (rc == MUTT_ABORT) return; else if (rc == MUTT_YES) mime_reply_any = true; diff --git a/remailer.c b/remailer.c index c40895b97..2b2a5b2b5 100644 --- a/remailer.c +++ b/remailer.c @@ -678,7 +678,8 @@ void mix_make_chain(struct ListHead *chainhead) { for (int i = 0; i < chain->cl; i++) { - if ((j = chain->ch[i])) + j = chain->ch[i]; + if (j != 0) t = type2_list[j]->shortname; else t = "*"; diff --git a/rfc2047.c b/rfc2047.c index e7af709fb..663ea75be 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -483,7 +483,8 @@ static int rfc2047_encode(const char *d, size_t dlen, int col, const char *fromc tocode = fromcode; if (icode) { - if ((tocode1 = mutt_choose_charset(icode, charsets, u, ulen, 0, 0))) + tocode1 = mutt_choose_charset(icode, charsets, u, ulen, 0, 0); + if (tocode1) tocode = tocode1; else { @@ -677,7 +678,8 @@ static int rfc2047_decode_word(char *d, const char *s, size_t len) case 2: /* ignore language specification a la RFC2231 */ t = pp1; - if ((t1 = memchr(pp, '*', t - pp))) + t1 = memchr(pp, '*', t - pp); + if (t1) t = t1; charset = mutt_str_substr_dup(pp, t); break; diff --git a/rfc2231.c b/rfc2231.c index c59295f5b..e5b377628 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -89,7 +89,8 @@ static char *rfc2231_get_charset(char *value, char *charset, size_t chslen) *t = '\0'; mutt_str_strfcpy(charset, value, chslen); - if ((u = strchr(t + 1, '\''))) + u = strchr(t + 1, '\''); + if (u) return u + 1; else return t + 1; @@ -177,7 +178,8 @@ static void rfc2231_join_continuations(struct Parameter **head, struct Rfc2231Pa mutt_str_strfcpy(attribute, par->attribute, sizeof(attribute)); - if ((encoded = par->encoded)) + encoded = par->encoded; + if (encoded != 0) valp = rfc2231_get_charset(par->value, charset, sizeof(charset)); else valp = par->value; @@ -195,7 +197,8 @@ static void rfc2231_join_continuations(struct Parameter **head, struct Rfc2231Pa q = par->next; rfc2231_free_parameter(&par); - if ((par = q)) + par = q; + if (par) valp = par->value; } while (par && (strcmp(par->attribute, attribute) == 0)); diff --git a/rfc3676.c b/rfc3676.c index b735f3eaf..2c8ca21f1 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -277,7 +277,8 @@ int rfc3676_handler(struct Body *a, struct State *s) memset(&fst, 0, sizeof(fst)); /* respect DelSp of RFC3676 only with f=f parts */ - if ((t = (char *) mutt_param_get("delsp", a->parameter))) + t = mutt_param_get("delsp", a->parameter); + if (t) { delsp = mutt_str_strlen(t) == 3 && (mutt_str_strncasecmp(t, "yes", 3) == 0); t = NULL; diff --git a/sendlib.c b/sendlib.c index 1a06c695a..e1eed0a67 100644 --- a/sendlib.c +++ b/sendlib.c @@ -390,7 +390,8 @@ int mutt_write_mime_header(struct Body *a, FILE *f) char *tmp = NULL; /* Strip off the leading path... */ - if ((t = strrchr(fn, '/'))) + t = strrchr(fn, '/'); + if (t) t++; else t = fn; @@ -1042,7 +1043,8 @@ int mutt_lookup_mime_type(struct Body *att, const char *path) while (fgets(buf, sizeof(buf) - 1, f) != NULL) { /* weed out any comments */ - if ((p = strchr(buf, '#'))) + p = strchr(buf, '#'); + if (p) *p = 0; /* remove any leading space. */ @@ -1557,7 +1559,8 @@ static bool check_boundary(const char *boundary, struct Body *b) if (b->next && check_boundary(boundary, b->next)) return true; - if ((p = mutt_param_get("boundary", b->parameter)) && (mutt_str_strcmp(p, boundary) == 0)) + p = mutt_param_get("boundary", b->parameter); + if (p && (mutt_str_strcmp(p, boundary) == 0)) { return true; } @@ -2153,7 +2156,8 @@ int mutt_write_rfc822_header(FILE *fp, struct Envelope *env, struct ListNode *tmp; STAILQ_FOREACH(tmp, &env->userhdrs, entries) { - if ((p = strchr(tmp->data, ':'))) + p = strchr(tmp->data, ':'); + if (p) { q = p; @@ -2230,7 +2234,8 @@ const char *mutt_fqdn(short may_hide_host) if (may_hide_host && option(OPT_HIDDEN_HOST)) { - if ((p = strchr(Hostname, '.'))) + p = strchr(Hostname, '.'); + if (p) p++; /* sanity check: don't hide the host if @@ -2606,8 +2611,8 @@ int mutt_invoke_sendmail(struct Address *from, struct Address *to, struct Addres if (!option(OPT_NO_CURSES)) mutt_need_hard_redraw(); - if ((i = send_msg(path, args, msg, option(OPT_NO_CURSES) ? NULL : &childout)) != - (EX_OK & 0xff)) + i = send_msg(path, args, msg, option(OPT_NO_CURSES) ? NULL : &childout); + if (i != (EX_OK & 0xff)) { if (i != S_BKG) { diff --git a/sidebar.c b/sidebar.c index 17d3b53ef..2a286f08f 100644 --- a/sidebar.c +++ b/sidebar.c @@ -252,8 +252,8 @@ static const char *sidebar_format_str(char *buf, size_t buflen, size_t col, int * mutt_expando_format to do the actual work. mutt_expando_format will callback to * us using sidebar_format_str() for the sidebar specific formatting characters. */ -static void make_sidebar_entry(char *buf, size_t buflen, int width, - char *box, struct SbEntry *sbe) +static void make_sidebar_entry(char *buf, size_t buflen, int width, char *box, + struct SbEntry *sbe) { if (!buf || !box || !sbe) return; diff --git a/smtp.c b/smtp.c index 3e722d300..723e77fa8 100644 --- a/smtp.c +++ b/smtp.c @@ -162,7 +162,8 @@ static int smtp_rcpt_to(struct Connection *conn, const struct Address *a) snprintf(buf, sizeof(buf), "RCPT TO:<%s>\r\n", a->mailbox); if (mutt_socket_write(conn, buf) == -1) return SMTP_ERR_WRITE; - if ((r = smtp_get_resp(conn))) + r = smtp_get_resp(conn); + if (r != 0) return r; a = a->next; } @@ -196,7 +197,8 @@ static int smtp_data(struct Connection *conn, const char *msgfile) mutt_file_fclose(&fp); return SMTP_ERR_WRITE; } - if ((r = smtp_get_resp(conn))) + r = smtp_get_resp(conn); + if (r != 0) { mutt_file_fclose(&fp); return r; @@ -234,7 +236,8 @@ static int smtp_data(struct Connection *conn, const char *msgfile) if (mutt_socket_write(conn, ".\r\n") == -1) return SMTP_ERR_WRITE; - if ((r = smtp_get_resp(conn))) + r = smtp_get_resp(conn); + if (r != 0) return r; return 0; @@ -579,10 +582,12 @@ static int smtp_open(struct Connection *conn) return -1; /* get greeting string */ - if ((rc = smtp_get_resp(conn))) + rc = smtp_get_resp(conn); + if (rc != 0) return rc; - if ((rc = smtp_helo(conn))) + rc = smtp_helo(conn); + if (rc != 0) return rc; #ifdef USE_SSL @@ -599,7 +604,8 @@ static int smtp_open(struct Connection *conn) { if (mutt_socket_write(conn, "STARTTLS\r\n") < 0) return SMTP_ERR_WRITE; - if ((rc = smtp_get_resp(conn))) + rc = smtp_get_resp(conn); + if (rc != 0) return rc; if (mutt_ssl_starttls(conn)) @@ -610,7 +616,8 @@ static int smtp_open(struct Connection *conn) } /* re-EHLO to get authentication mechanisms */ - if ((rc = smtp_helo(conn))) + rc = smtp_helo(conn); + if (rc != 0) return rc; } #endif @@ -668,7 +675,8 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, do { /* send our greeting */ - if ((rc = smtp_open(conn))) + rc = smtp_open(conn); + if (rc != 0) break; FREE(&AuthMechs); @@ -691,7 +699,8 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, rc = SMTP_ERR_WRITE; break; } - if ((rc = smtp_get_resp(conn))) + rc = smtp_get_resp(conn); + if (rc != 0) break; /* send the recipient list */ @@ -700,7 +709,8 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, break; /* send the message data */ - if ((rc = smtp_data(conn, msgfile))) + rc = smtp_data(conn, msgfile); + if (rc != 0) break; mutt_socket_write(conn, "QUIT\r\n"); diff --git a/url.c b/url.c index c2eee6895..3487f8c44 100644 --- a/url.c +++ b/url.c @@ -105,10 +105,12 @@ static int parse_query_string(struct Url *u, char *src) while (src && *src) { qs = mutt_mem_calloc(1, sizeof(struct UrlQueryString)); - if ((k = strchr(src, '&'))) + k = strchr(src, '&'); + if (k) *k = '\0'; - if ((v = strchr(src, '='))) + v = strchr(src, '='); + if (v) { *v = '\0'; qs->value = v + 1; @@ -173,23 +175,27 @@ int url_parse(struct Url *u, char *src) src += 2; - if ((t = strchr(src, '?'))) + t = strchr(src, '?'); + if (t) { *t++ = '\0'; if (parse_query_string(u, t) < 0) goto err; } - if ((u->path = strchr(src, '/'))) + u->path = strchr(src, '/'); + if (u->path) *u->path++ = '\0'; if (u->path && url_pct_decode(u->path) < 0) goto err; - if ((t = strrchr(src, '@'))) + t = strrchr(src, '@'); + if (t) { *t = '\0'; - if ((p = strchr(src, ':'))) + p = strchr(src, ':'); + if (p) { *p = '\0'; u->pass = p + 1; @@ -213,7 +219,8 @@ int url_parse(struct Url *u, char *src) else t = src; - if ((p = strchr(t, ':'))) + p = strchr(t, ':'); + if (p) { int num; *p++ = '\0'; @@ -357,7 +364,8 @@ int url_parse_mailto(struct Envelope *e, char **body, const char *src) if (!tmp) return -1; - if ((headers = strchr(tmp, '?'))) + headers = strchr(tmp, '?'); + if (headers) *headers++ = '\0'; if (url_pct_decode(tmp) < 0) @@ -369,7 +377,8 @@ int url_parse_mailto(struct Envelope *e, char **body, const char *src) for (; tag; tag = strtok_r(NULL, "&", &p)) { - if ((value = strchr(tag, '='))) + value = strchr(tag, '='); + if (value) *value++ = '\0'; if (!value || !*value) continue;