]> granicus.if.org Git - neomutt/commitdiff
split up 'if' statements that assign and test
authorRichard Russon <rich@flatcap.org>
Sat, 7 Oct 2017 10:24:25 +0000 (11:24 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 14 Oct 2017 14:32:46 +0000 (15:32 +0100)
Split 'if' statements that combine an assignment with a test.
e.g. from:

    if ((pc = imap_get_flags(&(idata->flags), pc)) == NULL)

To
    pc = imap_get_flags(&(idata->flags), pc);
    if (!pc)

This makes the statements a little easier to read and debug.

65 files changed:
alias.c
attach.c
browser.c
buffy.c
charset.c
color.c
commands.c
complete.c
compose.c
compress.c
copy.c
curs_lib.c
curs_main.c
doc/makedoc.c
edit.c
editmsg.c
filter.c
flags.c
handler.c
headers.c
help.c
history.c
imap/auth_cram.c
imap/imap.c
imap/message.c
init.c
keymap.c
lib/date.c
lib/file.c
main.c
mbox.c
menu.c
mh.c
mutt_socket.c
mutt_ssl.c
mutt_tunnel.c
muttlib.c
mx.c
ncrypt/crypt.c
ncrypt/crypt_gpgme.c
ncrypt/gnupgparse.c
ncrypt/pgp.c
ncrypt/pgpkey.c
ncrypt/pgpmicalg.c
ncrypt/smime.c
pager.c
parse.c
pattern.c
pgppubring.c
pop.c
postpone.c
recvattach.c
recvcmd.c
remailer.c
resize.c
rfc1524.c
rfc2047.c
rfc3676.c
rfc822.c
score.c
send.c
sendlib.c
system.c
thread.c
url.c

diff --git a/alias.c b/alias.c
index 17ac0b4bc928041d276185463b3fa979cde3068b..af6dd73917ae04396717c6f1391e28c67acad81b 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -358,7 +358,8 @@ retry_name:
       return;
     }
 
-    if ((new->addr = rfc822_parse_adrlist(new->addr, buf)) == NULL)
+    new->addr = rfc822_parse_adrlist(new->addr, buf);
+    if (!new->addr)
       BEEP();
     if (mutt_addrlist_to_intl(new->addr, &err))
     {
index 37999532e2fa659b75bc7a12129a2967af32fcd0..5768fd3c4008cb7ebd8f92c3c6cfaddd9b38671e 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -138,7 +138,8 @@ int mutt_compose_attachment(struct Body *a)
         int r;
 
         mutt_endwin(NULL);
-        if ((r = mutt_system(command)) == -1)
+        r = mutt_system(command);
+        if (r == -1)
           mutt_error(_("Error running \"%s\"!"), command);
 
         if (r != -1 && entry->composetypecommand)
@@ -147,7 +148,8 @@ int mutt_compose_attachment(struct Body *a)
           FILE *fp = NULL, *tfp = NULL;
           char tempfile[_POSIX_PATH_MAX];
 
-          if ((fp = safe_fopen(a->filename, "r")) == NULL)
+          fp = safe_fopen(a->filename, "r");
+          if (!fp)
           {
             mutt_perror(_("Failure to open file to parse headers."));
             goto bailout;
@@ -179,7 +181,8 @@ int mutt_compose_attachment(struct Body *a)
              * copying the file back */
             fseeko(fp, b->offset, SEEK_SET);
             mutt_mktemp(tempfile, sizeof(tempfile));
-            if ((tfp = safe_fopen(tempfile, "w")) == NULL)
+            tfp = safe_fopen(tempfile, "w");
+            if (!tfp)
             {
               mutt_perror(_("Failure to open file to strip headers."));
               goto bailout;
@@ -320,7 +323,8 @@ void mutt_check_lookup_list(struct Body *b, char *type, int len)
     {
       struct Body tmp = { 0 };
       int n;
-      if ((n = mutt_lookup_mime_type(&tmp, b->filename)) != TYPEOTHER)
+      n = mutt_lookup_mime_type(&tmp, b->filename);
+      if (n != TYPEOTHER)
       {
         snprintf(type, len, "%s/%s",
                  n == TYPEAUDIO ?
@@ -688,7 +692,8 @@ int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, char *outfi
 
     FILE *ifp = NULL, *ofp = NULL;
 
-    if ((ifp = fopen(b->filename, "r")) == NULL)
+    ifp = fopen(b->filename, "r");
+    if (!ifp)
     {
       mutt_perror("fopen");
       if (outfile && *outfile)
@@ -780,7 +785,8 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
         return -1;
       if (mx_open_mailbox(path, MUTT_APPEND | MUTT_QUIET, &ctx) == NULL)
         return -1;
-      if ((msg = mx_open_new_message(&ctx, hn, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM)) == NULL)
+      msg = mx_open_new_message(&ctx, hn, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
+      if (!msg)
       {
         mx_close_mailbox(&ctx, NULL);
         return -1;
@@ -805,7 +811,8 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
       struct State s;
 
       memset(&s, 0, sizeof(s));
-      if ((s.fpout = save_attachment_open(path, flags)) == NULL)
+      s.fpout = save_attachment_open(path, flags);
+      if (!s.fpout)
       {
         mutt_perror("fopen");
         mutt_sleep(2);
@@ -831,13 +838,15 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
 
     FILE *ofp = NULL, *nfp = NULL;
 
-    if ((ofp = fopen(m->filename, "r")) == NULL)
+    ofp = fopen(m->filename, "r");
+    if (!ofp)
     {
       mutt_perror("fopen");
       return -1;
     }
 
-    if ((nfp = save_attachment_open(path, flags)) == NULL)
+    nfp = save_attachment_open(path, flags);
+    if (!nfp)
     {
       mutt_perror("fopen");
       safe_fclose(&ofp);
@@ -904,7 +913,8 @@ int mutt_decode_save_attachment(FILE *fp, struct Body *m, char *path, int displa
       return -1;
     }
 
-    if ((s.fpin = fopen(m->filename, "r")) == NULL)
+    s.fpin = fopen(m->filename, "r");
+    if (!s.fpin)
     {
       mutt_perror("fopen");
       return -1;
@@ -1011,7 +1021,8 @@ int mutt_print_attachment(FILE *fp, struct Body *a)
     /* interactive program */
     if (piped)
     {
-      if ((ifp = fopen(newfile, "r")) == NULL)
+      ifp = fopen(newfile, "r");
+      if (!ifp)
       {
         mutt_perror("fopen");
         rfc1524_free_entry(&entry);
@@ -1065,7 +1076,8 @@ int mutt_print_attachment(FILE *fp, struct Body *a)
     {
       mutt_debug(2, "successfully decoded %s type attachment to %s\n", type, newfile);
 
-      if ((ifp = fopen(newfile, "r")) == NULL)
+      ifp = fopen(newfile, "r");
+      if (!ifp)
       {
         mutt_perror("fopen");
         goto bail0;
index e1caf83cc088187c5b79d24822ed4d5f662c832a..94445b7b3a1dfe530f230d97c2a11c6726853e90 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -716,7 +716,8 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
 
     mutt_buffy_check(false);
 
-    if ((dp = opendir(d)) == NULL)
+    dp = opendir(d);
+    if (!dp)
     {
       mutt_perror(d);
       return -1;
@@ -1696,7 +1697,8 @@ void _mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numf
             not = 1;
           }
 
-          if ((err = REGCOMP(rx, s, REG_NOSUB)) != 0)
+          err = REGCOMP(rx, s, REG_NOSUB);
+          if (err != 0)
           {
             regerror(err, rx, buf, sizeof(buf));
             FREE(&rx);
diff --git a/buffy.c b/buffy.c
index 6ac6430dac4c1db091d165b170f44d255fea87ed..9f10ecc1e14976b745bb6ac13c5d1d83cd310f6f 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -215,7 +215,8 @@ static int buffy_maildir_check_dir(struct Buffy *mailbox, const char *dir_name,
   if (!(check_new || check_stats))
     return rc;
 
-  if ((dirp = opendir(path)) == NULL)
+  dirp = opendir(path);
+  if (!dirp)
   {
     mailbox->magic = 0;
     return 0;
index 8208eaca3c5810077e2946d38a2565b7dc480b26..d75cd1adc112786f13ccd9d527682d411b0fab8a 100644 (file)
--- a/charset.c
+++ b/charset.c
@@ -348,7 +348,8 @@ iconv_t mutt_iconv_open(const char *tocode, const char *fromcode, int flags)
   fromcode2 = (fromcode2) ? fromcode2 : fromcode1;
 
   /* call system iconv with names it appreciates */
-  if ((cd = iconv_open(tocode2, fromcode2)) != (iconv_t) -1)
+  cd = iconv_open(tocode2, fromcode2);
+  if (cd != (iconv_t) -1)
     return cd;
 
   return (iconv_t) -1;
@@ -551,7 +552,8 @@ char *fgetconvs(char *buf, size_t l, FGETCONV *_fc)
 
   for (r = 0; r + 1 < l;)
   {
-    if ((c = fgetconv(_fc)) == EOF)
+    c = fgetconv(_fc);
+    if (c == EOF)
       break;
     buf[r++] = (char) c;
     if (c == '\n')
@@ -642,7 +644,8 @@ bool mutt_check_charset(const char *s, bool strict)
         return true;
     }
 
-  if ((cd = mutt_iconv_open(s, s, 0)) != (iconv_t)(-1))
+  cd = mutt_iconv_open(s, s, 0);
+  if (cd != (iconv_t)(-1))
   {
     iconv_close(cd);
     return true;
diff --git a/color.c b/color.c
index 50191027483e9bfe5e3f66549545453cf2525f1e..d884a3eaa5cf28d53b92fb5294467b3f42160bf8 100644 (file)
--- a/color.c
+++ b/color.c
@@ -497,7 +497,8 @@ static int _mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned lo
 
   mutt_extract_token(buf, s, 0);
 
-  if ((object = mutt_getvaluebyname(buf->data, Fields)) == -1)
+  object = mutt_getvaluebyname(buf->data, Fields);
+  if (object == -1)
   {
     snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
     return -1;
@@ -642,7 +643,8 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive,
     {
       strfcpy(buf, NONULL(s), sizeof(buf));
       mutt_check_simple(buf, sizeof(buf), NONULL(SimpleSearch));
-      if ((tmp->color_pattern = mutt_pattern_comp(buf, MUTT_FULL_MSG, err)) == NULL)
+      tmp->color_pattern = mutt_pattern_comp(buf, MUTT_FULL_MSG, err);
+      if (!tmp->color_pattern)
       {
         free_color_line(tmp, 1);
         return -1;
@@ -713,7 +715,8 @@ static int parse_object(struct Buffer *buf, struct Buffer *s, int *o, int *ql,
 
     mutt_extract_token(buf, s, 0);
 
-    if ((*o = mutt_getvaluebyname(buf->data, ComposeFields)) == -1)
+    *o = mutt_getvaluebyname(buf->data, ComposeFields);
+    if (*o == -1)
     {
       snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
       return (-1);
index 98ff9b810803467741ad60af6319d82973059951..932760f129c3f306694f808a787015df77d43964 100644 (file)
@@ -126,7 +126,8 @@ int mutt_display_message(struct Header *cur)
   }
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((fpout = safe_fopen(tempfile, "w")) == NULL)
+  fpout = safe_fopen(tempfile, "w");
+  if (!fpout)
   {
     mutt_error(_("Could not create temporary file!"));
     return 0;
@@ -237,7 +238,8 @@ int mutt_display_message(struct Header *cur)
 
     mutt_endwin(NULL);
     snprintf(buf, sizeof(buf), "%s %s", NONULL(Pager), tempfile);
-    if ((r = mutt_system(buf)) == -1)
+    r = mutt_system(buf);
+    if (r == -1)
       mutt_error(_("Error running \"%s\"!"), buf);
     unlink(tempfile);
     if (!option(OPT_NO_CURSES))
@@ -725,7 +727,8 @@ int _mutt_save_message(struct Header *h, struct Context *ctx, int delete, int de
   if (decode || decrypt)
     mutt_parse_mime_message(Context, h);
 
-  if ((rc = mutt_append_message(ctx, Context, h, cmflags, chflags)) != 0)
+  rc = mutt_append_message(ctx, Context, h, cmflags, chflags);
+  if (rc != 0)
     return rc;
 
   if (delete)
@@ -994,7 +997,8 @@ int mutt_edit_content_type(struct Header *h, struct Body *b, FILE *fp)
     int r;
     snprintf(tmp, sizeof(tmp), _("Convert to %s upon sending?"),
              mutt_get_parameter("charset", b->parameter));
-    if ((r = mutt_yesorno(tmp, !b->noconv)) != MUTT_ABORT)
+    r = mutt_yesorno(tmp, !b->noconv);
+    if (r != MUTT_ABORT)
       b->noconv = (r == MUTT_NO);
   }
 
@@ -1051,7 +1055,8 @@ static int _mutt_check_traditional_pgp(struct Header *h, int *redraw)
   h->security |= PGP_TRADITIONAL_CHECKED;
 
   mutt_parse_mime_message(Context, h);
-  if ((msg = mx_open_message(Context, h->msgno)) == NULL)
+  msg = mx_open_message(Context, h->msgno);
+  if (!msg)
     return 0;
   if (crypt_pgp_check_traditional(msg->fp, h->content, 0))
   {
index d392399ec72e76bd7cb1bb020475a41a0c1406d3..7bfd7fca5aa63b233169c7fba96b56c1575f4eb9 100644 (file)
@@ -205,7 +205,8 @@ int mutt_complete(char *s, size_t slen)
    * special case to handle when there is no filepart yet.  find the first
    * file/directory which is not ``.'' or ``..''
    */
-  if ((len = mutt_strlen(filepart)) == 0)
+  len = mutt_strlen(filepart);
+  if (len == 0)
   {
     while ((de = readdir(dirp)) != NULL)
     {
index b9baaf195dfac09501f71e2d80a343808dee0cd2..9d1958f2a11211c56242bc0f729e8484105a7f97 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -379,7 +379,8 @@ static int check_attachments(struct AttachCtx *actx)
       mutt_pretty_mailbox(pretty, sizeof(pretty));
       snprintf(msg, sizeof(msg), _("%s [#%d] modified. Update encoding?"), pretty, i + 1);
 
-      if ((r = mutt_yesorno(msg, MUTT_YES)) == MUTT_YES)
+      r = mutt_yesorno(msg, MUTT_YES);
+      if (r == MUTT_YES)
         mutt_update_encoding(actx->idx[i]->content);
       else if (r == MUTT_ABORT)
         return -1;
@@ -994,7 +995,8 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */
         if (!(WithCrypto & APPLICATION_PGP))
           break;
         new = safe_calloc(1, sizeof(struct AttachPtr));
-        if ((new->content = crypt_pgp_make_key_attachment(NULL)) != NULL)
+        new->content = crypt_pgp_make_key_attachment(NULL);
+        if (new->content)
         {
           update_idx(menu, actx, new);
           menu->redraw |= REDRAW_INDEX;
@@ -1421,7 +1423,8 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */
           continue;
         }
         *p++ = 0;
-        if ((itype = mutt_check_mime_type(type)) == TYPEOTHER)
+        itype = mutt_check_mime_type(type);
+        if (itype == TYPEOTHER)
         {
           mutt_error(_("Unknown Content-Type %s"), type);
           continue;
@@ -1436,7 +1439,8 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */
         }
         safe_fclose(&fp);
 
-        if ((new->content = mutt_make_file_attach(fname)) == NULL)
+        new->content = mutt_make_file_attach(fname);
+        if (!new->content)
         {
           mutt_error(_("What we have here is a failure to make an attachment"));
           FREE(&new);
@@ -1501,7 +1505,8 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */
         break;
 
       case OP_EXIT:
-        if ((i = query_quadoption(OPT_POSTPONE, _("Postpone this message?"))) == MUTT_NO)
+        i = query_quadoption(OPT_POSTPONE, _("Postpone this message?"));
+        if (i == MUTT_NO)
         {
           for (i = 0; i < actx->idxlen; i++)
             if (actx->idx[i]->unowned)
index 3dd28ee4bf4a9908505ab921b6b6002538281647..a7fd296ed683e76354393c704a01a01e3be576cb 100644 (file)
@@ -160,7 +160,8 @@ static int setup_paths(struct Context *ctx)
   mutt_mktemp(tmppath, sizeof(tmppath));
   ctx->path = safe_strdup(tmppath);
 
-  if ((tmpfp = safe_fopen(ctx->path, "w")) == NULL)
+  tmpfp = safe_fopen(ctx->path, "w");
+  if (!tmpfp)
     return -1;
 
   safe_fclose(&tmpfp);
diff --git a/copy.c b/copy.c
index ee0f5d28371522831c433603de784572b7ebb755..eccfdce0b8465019a3bd97ccf7628d868e05be2e 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -755,7 +755,8 @@ int mutt_copy_message(FILE *fpout, struct Context *src, struct Header *hdr,
   struct Message *msg = NULL;
   int r;
 
-  if ((msg = mx_open_message(src, hdr->msgno)) == NULL)
+  msg = mx_open_message(src, hdr->msgno);
+  if (!msg)
     return -1;
   if ((r = _mutt_copy_message(fpout, msg->fp, hdr, hdr->content, flags, chflags)) == 0 &&
       (ferror(fpout) || feof(fpout)))
@@ -792,7 +793,8 @@ static int _mutt_append_message(struct Context *dest, FILE *fpin,
   if (fgets(buf, sizeof(buf), fpin) == NULL)
     return -1;
 
-  if ((msg = mx_open_new_message(dest, hdr, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM)) == NULL)
+  msg = mx_open_new_message(dest, hdr, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
+  if (!msg)
     return -1;
   if (dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF)
     chflags |= CH_FROM | CH_FORCE_FROM;
@@ -816,7 +818,8 @@ int mutt_append_message(struct Context *dest, struct Context *src,
   struct Message *msg = NULL;
   int r;
 
-  if ((msg = mx_open_message(src, hdr->msgno)) == NULL)
+  msg = mx_open_message(src, hdr->msgno);
+  if (!msg)
     return -1;
   r = _mutt_append_message(dest, msg->fp, src, hdr, hdr->content, cmflags, chflags);
   mx_close_message(src, &msg);
@@ -1017,7 +1020,8 @@ static int address_header_decode(char **h)
       return 0;
   }
 
-  if ((a = rfc822_parse_adrlist(a, s + l)) == NULL)
+  a = rfc822_parse_adrlist(a, s + l);
+  if (!a)
     return 0;
 
   mutt_addrlist_to_local(a);
index bde0f1a9aa6144a056577570a04f9bb577cd1964..2810cfb271f8f8063f194c7ef0d6cc880e7942e0 100644 (file)
@@ -740,7 +740,8 @@ int mutt_window_mvprintw(struct MuttWindow *win, int row, int col, const char *f
   va_list ap;
   int rv;
 
-  if ((rv = mutt_window_move(win, row, col)) != ERR)
+  rv = mutt_window_move(win, row, col);
+  if (rv != ERR)
   {
     va_start(ap, fmt);
     rv = vw_printw(stdscr, fmt, ap);
index 6938a09a686792efe51f3fd926e20d4b536890ea..090f60898cd4e1c4ffdae471787ae88b6b7a53ae 100644 (file)
@@ -467,7 +467,8 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, size_t bufsz
       new_last_folder = safe_strdup(Context->path);
     *oldcount = Context ? Context->msgcount : 0;
 
-    if ((check = mx_close_mailbox(Context, index_hint)) != 0)
+    check = mx_close_mailbox(Context, index_hint);
+    if (check != 0)
     {
       if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED)
         update_index(menu, Context, check, *oldcount, *index_hint);
@@ -1034,7 +1035,8 @@ int mutt_index_menu(void)
     {
       /* check for new mail in the incoming folders */
       oldcount = newcount;
-      if ((newcount = mutt_buffy_check(false)) != oldcount)
+      newcount = mutt_buffy_check(false);
+      if (newcount != oldcount)
         menu->redraw |= REDRAW_STATUS;
       if (do_buffy_notify)
       {
@@ -1597,7 +1599,8 @@ int mutt_index_menu(void)
 
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
-        if ((menu->current = mutt_search_command(menu->current, op)) == -1)
+        menu->current = mutt_search_command(menu->current, op);
+        if (menu->current == -1)
           menu->current = menu->oldcurrent;
         else
           menu->redraw = REDRAW_MOTION;
@@ -1744,7 +1747,8 @@ int mutt_index_menu(void)
               newhdr = Context->hdrs[Context->v2r[newidx]];
           }
 
-          if ((check = mx_sync_mailbox(Context, &index_hint)) == 0)
+          check = mx_sync_mailbox(Context, &index_hint);
+          if (check == 0)
           {
             if (newhdr && Context->vcount != ovc)
               for (j = 0; j < Context->vcount; j++)
@@ -1928,7 +1932,8 @@ int mutt_index_menu(void)
           }
           if (option(OPT_RESOLVE))
           {
-            if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+            menu->current = ci_next_undeleted(menu->current);
+            if (menu->current == -1)
             {
               menu->current = menu->oldcurrent;
               menu->redraw = REDRAW_CURRENT;
@@ -2298,7 +2303,8 @@ int mutt_index_menu(void)
             mutt_error(_("You are on the last message."));
           break;
         }
-        if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+        menu->current = ci_next_undeleted(menu->current);
+        if (menu->current == -1)
         {
           menu->current = menu->oldcurrent;
           if (menu->menu == MENU_MAIN)
@@ -2342,7 +2348,8 @@ int mutt_index_menu(void)
           mutt_error(_("You are on the first message."));
           break;
         }
-        if ((menu->current = ci_previous_undeleted(menu->current)) == -1)
+        menu->current = ci_previous_undeleted(menu->current);
+        if (menu->current == -1)
         {
           menu->current = menu->oldcurrent;
           if (menu->menu == MENU_MAIN)
@@ -2399,7 +2406,8 @@ int mutt_index_menu(void)
             menu->redraw |= REDRAW_INDEX;
           else if (option(OPT_RESOLVE))
           {
-            if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+            menu->current = ci_next_undeleted(menu->current);
+            if (menu->current == -1)
             {
               menu->current = menu->oldcurrent;
               menu->redraw |= REDRAW_CURRENT;
@@ -2532,7 +2540,8 @@ int mutt_index_menu(void)
           mutt_set_flag(Context, CURHDR, MUTT_FLAG, !CURHDR->flagged);
           if (option(OPT_RESOLVE))
           {
-            if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+            menu->current = ci_next_undeleted(menu->current);
+            if (menu->current == -1)
             {
               menu->current = menu->oldcurrent;
               menu->redraw |= REDRAW_CURRENT;
@@ -2578,7 +2587,8 @@ int mutt_index_menu(void)
 
           if (option(OPT_RESOLVE))
           {
-            if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+            menu->current = ci_next_undeleted(menu->current);
+            if (menu->current == -1)
             {
               menu->current = menu->oldcurrent;
               menu->redraw |= REDRAW_CURRENT;
@@ -2676,7 +2686,8 @@ int mutt_index_menu(void)
             menu->redraw |= REDRAW_INDEX;
           else if (option(OPT_RESOLVE))
           {
-            if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+            menu->current = ci_next_undeleted(menu->current);
+            if (menu->current == -1)
             {
               menu->current = menu->oldcurrent;
               menu->redraw |= REDRAW_CURRENT;
@@ -2781,7 +2792,8 @@ int mutt_index_menu(void)
             mutt_set_flag(Context, CURHDR, MUTT_TAG, 0);
           if (option(OPT_RESOLVE))
           {
-            if ((menu->current = ci_next_undeleted(menu->current)) == -1)
+            menu->current = ci_next_undeleted(menu->current);
+            if (menu->current == -1)
             {
               menu->current = menu->oldcurrent;
               menu->redraw |= REDRAW_CURRENT;
index 39cc068b0d4c13ba7347ce0ac990709090c65976..d4b6d23436ec72c2d12c50ca526c6c3bf0256124 100644 (file)
@@ -1351,7 +1351,8 @@ static void makedoc(FILE *in, FILE *out)
   while ((fgets(buffer, sizeof(buffer), in)))
   {
     line++;
-    if ((p = strchr(buffer, '\n')) == NULL)
+    p = strchr(buffer, '\n');
+    if (!p)
     {
       fprintf(stderr, "%s: Line %d too long.  Ask a wizard to enlarge\n"
                       "%s: my buffer size.\n",
@@ -1424,7 +1425,8 @@ int main(int argc, char *argv[])
 
   if (optind != argc)
   {
-    if ((f = fopen(argv[optind], "r")) == NULL)
+    f = fopen(argv[optind], "r");
+    if (!f)
     {
       fprintf(stderr, "%s: Can't open %s (%s).\n", Progname, argv[optind], strerror(errno));
       exit(1);
diff --git a/edit.c b/edit.c
index fd693c4a2c1544e65996d174b6c484a88038be75..a228f064f2de3e607c8ea61bbe357672c41894c3 100644 (file)
--- a/edit.c
+++ b/edit.c
@@ -137,7 +137,8 @@ static int be_barf_file(const char *path, char **buf, int buflen)
 {
   FILE *f = NULL;
 
-  if ((f = fopen(path, "w")) == NULL)
+  f = fopen(path, "w");
+  if (!f)
   {
     addstr(strerror(errno));
     addch('\n');
index ebeb3e556bd534614124924c13aaf436c734c1df..33de5a5d764ffa4dc61342cc1b3e9378ed9804a5 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -99,7 +99,8 @@ static int edit_one_message(struct Context *ctx, struct Header *cur)
     goto bail;
   }
 
-  if ((rc = stat(tmp, &sb)) == -1)
+  rc = stat(tmp, &sb);
+  if (rc == -1)
   {
     mutt_error(_("Can't stat %s: %s"), tmp, strerror(errno));
     goto bail;
@@ -121,7 +122,8 @@ static int edit_one_message(struct Context *ctx, struct Header *cur)
 
   mutt_edit_file(NONULL(Editor), tmp);
 
-  if ((rc = stat(tmp, &sb)) == -1)
+  rc = stat(tmp, &sb);
+  if (rc == -1)
   {
     mutt_error(_("Can't stat %s: %s"), tmp, strerror(errno));
     goto bail;
@@ -141,7 +143,8 @@ static int edit_one_message(struct Context *ctx, struct Header *cur)
     goto bail;
   }
 
-  if ((fp = fopen(tmp, "r")) == NULL)
+  fp = fopen(tmp, "r");
+  if (!fp)
   {
     rc = -1;
     mutt_error(_("Can't open message file: %s"), strerror(errno));
@@ -184,7 +187,8 @@ static int edit_one_message(struct Context *ctx, struct Header *cur)
     goto bail;
   }
 
-  if ((rc = mutt_copy_hdr(fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL)) == 0)
+  rc = mutt_copy_hdr(fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL);
+  if (rc == 0)
   {
     fputc('\n', msg->fp);
     mutt_copy_stream(fp, msg->fp);
index 62af41f8567581da179697f84285bd2cb6103e3e..bef7276e72784f264e8f041f20e3a5e1f151f37d 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -100,7 +100,8 @@ pid_t mutt_create_filter_fd(const char *cmd, FILE **in, FILE **out, FILE **err,
 
   mutt_block_signals_system();
 
-  if ((thepid = fork()) == 0)
+  thepid = fork();
+  if (thepid == 0)
   {
     mutt_unblock_signals_system(0);
 
diff --git a/flags.c b/flags.c
index d3b8ab50e27256f0617266024be89938ef4cc9b8..ef8c18d2c69740942edf6ab13ae2c53984df00da 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -357,7 +357,8 @@ int mutt_thread_set_flag(struct Header *hdr, int flag, int bf, int subthread)
   if (cur->message && cur != hdr->thread)
     mutt_set_flag(Context, cur->message, flag, bf);
 
-  if ((cur = cur->child) == NULL)
+  cur = cur->child;
+  if (!cur)
     goto done;
 
   while (true)
index 6ee1349d9463a6cf61867af2e442210ca22f5675..91d940985c9651bb2d80b1dca2427e71a20424c4 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -144,7 +144,8 @@ static void decode_xbit(struct State *s, long len, int istext, iconv_t cd)
     {
       if (c == '\r' && len)
       {
-        if ((ch = fgetc(s->fpin)) == '\n')
+        ch = fgetc(s->fpin);
+        if (ch == '\n')
         {
           c = ch;
           len--;
@@ -319,7 +320,8 @@ void mutt_decode_base64(struct State *s, long len, int istext, iconv_t cd)
   {
     for (i = 0; i < 4 && len > 0; len--)
     {
-      if ((ch = fgetc(s->fpin)) == EOF)
+      ch = fgetc(s->fpin);
+      if (ch == EOF)
         break;
       if (ch >= 0 && ch < 128 && (base64val(ch) != -1 || ch == '='))
         buf[i++] = ch;
@@ -970,7 +972,8 @@ static int is_mmnoask(const char *buf)
 
     while ((p = strtok(p, ",")) != NULL)
     {
-      if ((q = strrchr(p, '/')) != NULL)
+      q = strrchr(p, '/');
+      if (q)
       {
         if (*(q + 1) == '*')
         {
@@ -1415,7 +1418,8 @@ static int autoview_handler(struct Body *a, struct State *s)
       mutt_message(_("Invoking autoview command: %s"), command);
     }
 
-    if ((fpin = safe_fopen(tempfile, "w+")) == NULL)
+    fpin = safe_fopen(tempfile, "w+");
+    if (!fpin)
     {
       mutt_perror("fopen");
       rfc1524_free_entry(&entry);
@@ -1723,7 +1727,8 @@ static int run_decode_and_handler(struct Body *b, struct State *s,
       }
 #else
       mutt_mktemp(tempfile, sizeof(tempfile));
-      if ((s->fpout = safe_fopen(tempfile, "w")) == NULL)
+      s->fpout = safe_fopen(tempfile, "w");
+      if (!s->fpout)
       {
         mutt_error(_("Unable to open temporary file!"));
         mutt_debug(1, "Can't open %s.\n", tempfile);
index f9de5acdc789073d0408f732c25c1bbd89d4aa6e..b315a0ebca75b491bbf18da88302b55d01738271 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -56,7 +56,8 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg,
   struct stat st;
 
   mutt_mktemp(path, sizeof(path));
-  if ((ofp = safe_fopen(path, "w")) == NULL)
+  ofp = safe_fopen(path, "w");
+  if (!ofp)
   {
     mutt_perror(path);
     return;
@@ -67,7 +68,8 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg,
   fputc('\n', ofp); /* tie off the header. */
 
   /* now copy the body of the message. */
-  if ((ifp = fopen(body, "r")) == NULL)
+  ifp = fopen(body, "r");
+  if (!ifp)
   {
     mutt_perror(body);
     safe_fclose(&ofp);
@@ -101,13 +103,15 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg,
   mutt_list_free(&msg->env->userhdrs);
 
   /* Read the temp file back in */
-  if ((ifp = fopen(path, "r")) == NULL)
+  ifp = fopen(path, "r");
+  if (!ifp)
   {
     mutt_perror(path);
     return;
   }
 
-  if ((ofp = safe_fopen(body, "w")) == NULL)
+  ofp = safe_fopen(body, "w");
+  if (!ofp)
   {
     /* intentionally leak a possible temporary file here */
     safe_fclose(&ifp);
diff --git a/help.c b/help.c
index 941ac373ccd21831d54cafff93fee7468ca1c253..c73761aeb1c38d3d2c8c8dd3bd940e521b83b1cf 100644 (file)
--- a/help.c
+++ b/help.c
@@ -358,7 +358,8 @@ void mutt_help(int menu)
 
   do
   {
-    if ((f = safe_fopen(t, "w")) == NULL)
+    f = safe_fopen(t, "w");
+    if (!f)
     {
       mutt_perror(t);
       return;
index 199450f459100e7e2c79a13a591c289ec8505b05..e8a9432a9c0e6efa21b36db2a4178f1bcda9cdf0 100644 (file)
--- a/history.c
+++ b/history.c
@@ -120,7 +120,8 @@ void mutt_read_histfile(void)
   char *linebuf = NULL, *p = NULL;
   size_t buflen;
 
-  if ((f = fopen(HistoryFile, "r")) == NULL)
+  f = fopen(HistoryFile, "r");
+  if (!f)
     return;
 
   while ((linebuf = mutt_read_line(linebuf, &buflen, f, &line, 0)) != NULL)
@@ -200,7 +201,8 @@ static void shrink_histfile(void)
   bool regen_file = false;
   struct Hash *dup_hashes[HC_LAST] = { 0 };
 
-  if ((f = fopen(HistoryFile, "r")) == NULL)
+  f = fopen(HistoryFile, "r");
+  if (!f)
     return;
 
   if (option(OPT_HISTORY_REMOVE_DUPS))
@@ -240,7 +242,8 @@ static void shrink_histfile(void)
   if (regen_file)
   {
     mutt_mktemp(tmpfname, sizeof(tmpfname));
-    if ((tmp = safe_fopen(tmpfname, "w+")) == NULL)
+    tmp = safe_fopen(tmpfname, "w+");
+    if (!tmp)
     {
       mutt_perror(tmpfname);
       goto cleanup;
@@ -295,7 +298,8 @@ static void save_history(enum HistoryClass hclass, const char *s)
   if (!s || !*s) /* This shouldn't happen, but it's safer. */
     return;
 
-  if ((f = fopen(HistoryFile, "a")) == NULL)
+  f = fopen(HistoryFile, "a");
+  if (!f)
   {
     mutt_perror("fopen");
     return;
index df322287e35e8c4ad59d3c654dd86ccac6ab1aea..c0ab6922295c38371626524040de099981dc506b 100644 (file)
@@ -79,7 +79,8 @@ enum ImapAuthRes imap_auth_cram_md5(struct ImapData *idata, const char *method)
     goto bail;
   }
 
-  if ((len = mutt_from_base64(obuf, idata->buf + 2)) == -1)
+  len = mutt_from_base64(obuf, idata->buf + 2);
+  if (len == -1)
   {
     mutt_debug(1, "Error decoding base64 response.\n");
     goto bail;
index c5d6eb163d4b5103ddb393e0c2556c06c405f455..98fd31c676c27f9138a72621b01c4cf226f73799 100644 (file)
@@ -493,7 +493,8 @@ int imap_open_connection(struct ImapData *idata)
         goto err_close_conn;
       if (rc == MUTT_YES)
       {
-        if ((rc = imap_exec(idata, "STARTTLS", IMAP_CMD_FAIL_OK)) == -1)
+        rc = imap_exec(idata, "STARTTLS", IMAP_CMD_FAIL_OK);
+        if (rc == -1)
           goto bail;
         if (rc != -2)
         {
@@ -696,7 +697,8 @@ static int imap_open_mailbox(struct Context *ctx)
   {
     char *pc = NULL;
 
-    if ((rc = imap_cmd_step(idata)) != IMAP_CMD_CONTINUE)
+    rc = imap_cmd_step(idata);
+    if (rc != IMAP_CMD_CONTINUE)
       break;
 
     pc = idata->buf + 2;
@@ -709,7 +711,8 @@ static int imap_open_mailbox(struct Context *ctx)
       if (STAILQ_EMPTY(&idata->flags))
       {
         mutt_debug(3, "Getting mailbox FLAGS\n");
-        if ((pc = imap_get_flags(&idata->flags, pc)) == NULL)
+        pc = imap_get_flags(&idata->flags, pc);
+        if (!pc)
           goto fail;
       }
     }
@@ -721,7 +724,8 @@ static int imap_open_mailbox(struct Context *ctx)
       mutt_list_free(&idata->flags);
       /* skip "OK [PERMANENT" so syntax is the same as FLAGS */
       pc += 13;
-      if ((pc = imap_get_flags(&(idata->flags), pc)) == NULL)
+      pc = imap_get_flags(&(idata->flags), pc);
+      if (!pc)
         goto fail;
     }
     /* save UIDVALIDITY for the header cache */
@@ -849,7 +853,8 @@ static int imap_open_mailbox_append(struct Context *ctx, int flags)
     strfcpy(mailbox, "INBOX", sizeof(mailbox));
   FREE(&mx.mbox);
 
-  if ((rc = imap_access(ctx->path)) == 0)
+  rc = imap_access(ctx->path);
+  if (rc == 0)
     return 0;
 
   if (rc == -1)
@@ -889,7 +894,8 @@ static int imap_open_new_message(struct Message *msg, struct Context *dest, stru
   char tmp[_POSIX_PATH_MAX];
 
   mutt_mktemp(tmp, sizeof(tmp));
-  if ((msg->fp = safe_fopen(tmp, "w")) == NULL)
+  msg->fp = safe_fopen(tmp, "w");
+  if (!msg->fp)
   {
     mutt_perror(tmp);
     return -1;
@@ -1460,7 +1466,8 @@ int imap_sync_mailbox(struct Context *ctx, int expunge)
    * to be changed. */
   imap_allow_reopen(ctx);
 
-  if ((rc = imap_check(idata, 0)) != 0)
+  rc = imap_check(idata, 0);
+  if (rc != 0)
     return rc;
 
   /* if we are expunging anyway, we can do deleted messages very quickly... */
index a6c88cd38694ba9978f24d9c55a0d705a62ebee6..14464f4b482b743f6cf0dba0f3c223a49cca16c4 100644 (file)
@@ -255,7 +255,8 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s)
 
     if (mutt_strncasecmp("FLAGS", s, 5) == 0)
     {
-      if ((s = msg_parse_flags(h, s)) == NULL)
+      s = msg_parse_flags(h, s);
+      if (!s)
         return -1;
     }
     else if (mutt_strncasecmp("UID", s, 3) == 0)
@@ -932,7 +933,8 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno)
   imap_cmd_start(idata, buf);
   do
   {
-    if ((rc = imap_cmd_step(idata)) != IMAP_CMD_CONTINUE)
+    rc = imap_cmd_step(idata);
+    if (rc != IMAP_CMD_CONTINUE)
       break;
 
     pc = idata->buf;
@@ -972,7 +974,8 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno)
                                 output_progress ? &progressbar : NULL) < 0)
             goto bail;
           /* pick up trailing line */
-          if ((rc = imap_cmd_step(idata)) != IMAP_CMD_CONTINUE)
+          rc = imap_cmd_step(idata);
+          if (rc != IMAP_CMD_CONTINUE)
             goto bail;
           pc = idata->buf;
 
@@ -984,7 +987,8 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno)
          * incrementally update flags later, this won't stop us syncing */
         else if ((mutt_strncasecmp("FLAGS", pc, 5) == 0) && !h->changed)
         {
-          if ((pc = imap_set_flags(idata, h, pc, NULL)) == NULL)
+          pc = imap_set_flags(idata, h, pc, NULL);
+          if (!pc)
             goto bail;
         }
       }
@@ -1099,7 +1103,8 @@ int imap_append_message(struct Context *ctx, struct Message *msg)
   if (!*mailbox)
     strfcpy(mailbox, "INBOX", sizeof(mailbox));
 
-  if ((fp = fopen(msg->path, "r")) == NULL)
+  fp = fopen(msg->path, "r");
+  if (!fp)
   {
     mutt_perror(msg->path);
     goto fail;
@@ -1477,7 +1482,8 @@ char *imap_set_flags(struct ImapData *idata, struct Header *h, char *s, int *ser
   memcpy(&old_hd, hd, sizeof(old_hd));
 
   mutt_debug(2, "imap_set_flags: parsing FLAGS\n");
-  if ((s = msg_parse_flags(&newh, s)) == NULL)
+  s = msg_parse_flags(&newh, s);
+  if (!s)
     return NULL;
 
   /* Update tags system */
diff --git a/init.c b/init.c
index 59eddb4da355392fcac895064bba3744e105f2ae..4d2eb68ef177a4e7694940d92e3a8ae85f19b043 100644 (file)
--- a/init.c
+++ b/init.c
@@ -170,7 +170,8 @@ static int parse_regex(int idx, struct Buffer *tmp, struct Buffer *err)
     }
 
     rx = safe_malloc(sizeof(regex_t));
-    if ((e = REGCOMP(rx, p, flags)) != 0)
+    e = REGCOMP(rx, p, flags);
+    if (e != 0)
     {
       regerror(e, rx, err->data, err->dsize);
       FREE(&rx);
@@ -352,7 +353,8 @@ static int parse_sort(short *val, const char *s, const struct Mapping *map, stru
     flags |= SORT_LAST;
   }
 
-  if ((i = mutt_getvaluebyname(s, map)) == -1)
+  i = mutt_getvaluebyname(s, map);
+  if (i == -1)
   {
     snprintf(err->data, err->dsize, _("%s: unknown sorting method"), s);
     return -1;
@@ -1489,7 +1491,8 @@ static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data,
           break;
 
         case GS_ADDR:
-          if ((addr = mutt_parse_adrlist(NULL, buf->data)) == NULL)
+          addr = mutt_parse_adrlist(NULL, buf->data);
+          if (!addr)
             goto bail;
           if (mutt_addrlist_to_intl(addr, &estr))
           {
@@ -2311,7 +2314,8 @@ static void start_debug(void)
     rename(debugfilename, buf);
   }
 
-  if ((debugfile = safe_fopen(debugfilename, "w")) != NULL)
+  debugfile = safe_fopen(debugfilename, "w");
+  if (debugfile)
   {
     setbuf(debugfile, NULL); /* don't buffer the debugging output! */
     mutt_debug(1, "NeoMutt/%s debugging at level %d\n", PACKAGE_VERSION, debuglevel);
@@ -3200,7 +3204,8 @@ static int source_rc(const char *rcfile_path, struct Buffer *err)
 
   mutt_debug(2, "Reading configuration file '%s'.\n", rcfile);
 
-  if ((f = mutt_open_read(rcfile, &pid)) == NULL)
+  f = mutt_open_read(rcfile, &pid);
+  if (!f)
   {
     snprintf(err->data, err->dsize, "%s: %s", rcfile, strerror(errno));
     return -1;
@@ -3632,9 +3637,11 @@ int mutt_var_value_complete(char *buffer, size_t len, int pos)
       return 0;
 
     var[vlen - 1] = '\0';
-    if ((idx = mutt_option_index(var)) == -1)
+    idx = mutt_option_index(var);
+    if (idx == -1)
     {
-      if ((myvarval = myvar_get(var)) != NULL)
+      myvarval = myvar_get(var);
+      if (myvarval)
       {
         pretty_var(pt, len - (pt - buffer), var, myvarval);
         return 1;
@@ -4228,7 +4235,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands)
   Editor = safe_strdup(p);
   Visual = safe_strdup(p);
 
-  if ((p = getenv("REPLYTO")) != NULL)
+  p = getenv("REPLYTO");
+  if (p)
   {
     struct Buffer buf, token;
 
@@ -4243,7 +4251,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands)
     FREE(&token.data);
   }
 
-  if ((p = getenv("EMAIL")) != NULL)
+  p = getenv("EMAIL");
+  if (p)
     From = rfc822_parse_adrlist(NULL, p);
 
   mutt_set_langinfo_charset();
index c43ec87215e87b3b6b934173f053915dfc8f2f2c..38f4a04adc4d56bab84f2e1f6fa650b226f99d61 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -202,7 +202,8 @@ static int parsekeys(const char *str, keycode_t *d, int max)
       c = *t;
       *t = '\0';
 
-      if ((n = mutt_getvaluebyname(s, KeyNames)) != -1)
+      n = mutt_getvaluebyname(s, KeyNames);
+      if (n != -1)
       {
         s = t;
         *d = n;
@@ -1090,7 +1091,8 @@ int mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data,
   char *key = NULL;
   int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = 0, nummenus;
 
-  if ((key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err)) == NULL)
+  key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err);
+  if (!key)
     return -1;
 
   /* function to execute */
@@ -1147,7 +1149,8 @@ int mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data,
   char *seq = NULL;
   char *key = NULL;
 
-  if ((key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err)) == NULL)
+  key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err);
+  if (!key)
     return -1;
 
   mutt_extract_token(buf, s, MUTT_TOKEN_CONDENSE);
index a668d4a999859b1cd2379a169b3b733d7a118a1e..0ac522fbf8f6831d62e724d6b4b4d9dcdb71309d 100644 (file)
@@ -560,7 +560,8 @@ time_t mutt_parse_date(const char *s, struct Tz *tz_out)
           /* ad hoc support for the European MET (now officially CET) TZ */
           if (mutt_strcasecmp(t, "MET") == 0)
           {
-            if ((t = strtok(NULL, " \t")) != NULL)
+            t = strtok(NULL, " \t");
+            if (t)
             {
               if (mutt_strcasecmp(t, "DST") == 0)
                 zhours++;
index 0fbee2d988eff318b0b04760dacef68f644505c7..6a6fcf6668bda246de3b56ad1d51253e2bb2a885 100644 (file)
@@ -650,7 +650,8 @@ char *mutt_read_line(char *s, size_t *size, FILE *fp, int *line, int flags)
       FREE(&s);
       return NULL;
     }
-    if ((ch = strchr(s + offset, '\n')) != NULL)
+    ch = strchr(s + offset, '\n');
+    if (ch)
     {
       if (line)
         (*line)++;
diff --git a/main.c b/main.c
index 11f501d28887ee0ed5eb50de30ceb356e835a894..292fdc0bf5f00ad65b9e3ee1acff24d2c69c9e99 100644 (file)
--- a/main.c
+++ b/main.c
@@ -632,7 +632,8 @@ int main(int argc, char **argv, char **env)
         {
           strfcpy(expanded_infile, infile, sizeof(expanded_infile));
           mutt_expand_path(expanded_infile, sizeof(expanded_infile));
-          if ((fin = fopen(expanded_infile, "r")) == NULL)
+          fin = fopen(expanded_infile, "r");
+          if (!fin)
           {
             if (!option(OPT_NO_CURSES))
               mutt_endwin(NULL);
@@ -651,7 +652,8 @@ int main(int argc, char **argv, char **env)
         mutt_mktemp(buf, sizeof(buf));
         tempfile = safe_strdup(buf);
 
-        if ((fout = safe_fopen(tempfile, "w")) == NULL)
+        fout = safe_fopen(tempfile, "w");
+        if (!fout)
         {
           if (!option(OPT_NO_CURSES))
             mutt_endwin(NULL);
@@ -670,7 +672,8 @@ int main(int argc, char **argv, char **env)
           fputs(bodytext, fout);
         safe_fclose(&fout);
 
-        if ((fin = fopen(tempfile, "r")) == NULL)
+        fin = fopen(tempfile, "r");
+        if (!fin)
         {
           if (!option(OPT_NO_CURSES))
             mutt_endwin(NULL);
@@ -796,7 +799,8 @@ int main(int argc, char **argv, char **env)
           perror(expanded_infile);
           exit(1);
         }
-        if ((fout = safe_fopen(expanded_infile, "a")) == NULL)
+        fout = safe_fopen(expanded_infile, "a");
+        if (!fout)
         {
           if (!option(OPT_NO_CURSES))
             mutt_endwin(NULL);
diff --git a/mbox.c b/mbox.c
index 55df64cf9fa9a51f9154007130fe680291bf095c..78476973d02fd6c1065c1ecce6f2442159e21f14 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -75,7 +75,8 @@ static int mbox_lock_mailbox(struct Context *ctx, int excl, int retry)
 {
   int r;
 
-  if ((r = mutt_lock_file(ctx->path, fileno(ctx->fp), excl, retry)) == 0)
+  r = mutt_lock_file(ctx->path, fileno(ctx->fp), excl, retry);
+  if (r == 0)
     ctx->locked = true;
   else if (retry && !excl)
   {
@@ -440,7 +441,8 @@ static int mbox_open_mailbox(struct Context *ctx)
 {
   int rc;
 
-  if ((ctx->fp = fopen(ctx->path, "r")) == NULL)
+  ctx->fp = fopen(ctx->path, "r");
+  if (!ctx->fp)
   {
     mutt_perror(ctx->path);
     return -1;
@@ -1043,7 +1045,8 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
   /* need to open the file for writing in such a way that it does not truncate
    * the file, so use read-write mode.
    */
-  if ((ctx->fp = freopen(ctx->path, "r+", ctx->fp)) == NULL)
+  ctx->fp = freopen(ctx->path, "r+", ctx->fp);
+  if (!ctx->fp)
   {
     mx_fastclose_mailbox(ctx);
     mutt_error(_("Fatal error!  Could not reopen mailbox!"));
@@ -1225,7 +1228,8 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
     goto bail;
   }
 
-  if ((fp = fopen(tempfile, "r")) == NULL)
+  fp = fopen(tempfile, "r");
+  if (!fp)
   {
     mutt_unblock_signals();
     mx_fastclose_mailbox(ctx);
@@ -1307,7 +1311,8 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint)
   mbox_reset_atime(ctx, &statbuf);
 
   /* reopen the mailbox in read-only mode */
-  if ((ctx->fp = fopen(ctx->path, "r")) == NULL)
+  ctx->fp = fopen(ctx->path, "r");
+  if (!ctx->fp)
   {
     unlink(tempfile);
     mutt_unblock_signals();
@@ -1367,7 +1372,8 @@ bail: /* Come here in case of disaster */
   FREE(&newOffset);
   FREE(&oldOffset);
 
-  if ((ctx->fp = freopen(ctx->path, "r", ctx->fp)) == NULL)
+  ctx->fp = freopen(ctx->path, "r", ctx->fp);
+  if (!ctx->fp)
   {
     mutt_error(_("Could not reopen mailbox!"));
     mx_fastclose_mailbox(ctx);
diff --git a/menu.c b/menu.c
index b37b2ae3269a49a61a00da9a87fc31781a4754e3..ebd1bdfd779dd333edcbf5970aa4faa9fc2b906c 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1241,7 +1241,8 @@ int mutt_menu_loop(struct Menu *menu)
         if (menu->search && !menu->dialog) /* Searching dialogs won't work */
         {
           menu->oldcurrent = menu->current;
-          if ((menu->current = menu_search(menu, i)) != -1)
+          menu->current = menu_search(menu, i);
+          if (menu->current != -1)
             menu->redraw = REDRAW_MOTION;
           else
             menu->current = menu->oldcurrent;
diff --git a/mh.c b/mh.c
index 074b321dd91f2e7f443fc521dd58e9fc07daf455..245e676794e50757d0e2dd9b11056e2b47ab45a3 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -356,7 +356,8 @@ bool mh_buffy(struct Buffy *mailbox, bool check_stats)
 
   if (check_stats)
   {
-    if ((dirp = opendir(mailbox->path)) != NULL)
+    dirp = opendir(mailbox->path);
+    if (dirp)
     {
       while ((de = readdir(dirp)) != NULL)
       {
@@ -383,7 +384,8 @@ static int mh_mkstemp(struct Context *dest, FILE **fp, char **tgt)
   {
     snprintf(path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%" PRIu64, dest->path,
              NONULL(ShortHostname), (int) getpid(), mutt_rand64());
-    if ((fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
+    fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
+    if (fd == -1)
     {
       if (errno != EEXIST)
       {
@@ -400,7 +402,8 @@ static int mh_mkstemp(struct Context *dest, FILE **fp, char **tgt)
   }
   umask(omask);
 
-  if ((*fp = fdopen(fd, "w")) == NULL)
+  *fp = fdopen(fd, "w");
+  if (!*fp)
   {
     FREE(tgt);
     close(fd);
@@ -817,7 +820,8 @@ struct Header *maildir_parse_message(int magic, const char *fname, int is_old,
 {
   FILE *f = NULL;
 
-  if ((f = fopen(fname, "r")) != NULL)
+  f = fopen(fname, "r");
+  if (f)
   {
     h = maildir_parse_stream(magic, f, fname, is_old, h);
     safe_fclose(&f);
@@ -844,7 +848,8 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last,
   else
     strfcpy(buf, ctx->path, sizeof(buf));
 
-  if ((dirp = opendir(buf)) == NULL)
+  dirp = opendir(buf);
+  if (!dirp)
     return -1;
 
   while (((de = readdir(dirp)) != NULL) && (SigInt != 1))
@@ -1387,7 +1392,8 @@ static int mh_open_mailbox_append(struct Context *ctx, int flags)
     }
 
     snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", ctx->path);
-    if ((i = creat(tmp, S_IRWXU)) == -1)
+    i = creat(tmp, S_IRWXU);
+    if (i == -1)
     {
       mutt_perror(tmp);
       rmdir(ctx->path);
@@ -1518,7 +1524,8 @@ static int maildir_open_new_message(struct Message *msg, struct Context *dest,
 
     mutt_debug(2, "maildir_open_new_message (): Trying %s.\n", path);
 
-    if ((fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
+    fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
+    if (fd == -1)
     {
       if (errno != EEXIST)
       {
@@ -1536,7 +1543,8 @@ static int maildir_open_new_message(struct Message *msg, struct Context *dest,
   }
   umask(omask);
 
-  if ((msg->fp = fdopen(fd, "w")) == NULL)
+  msg->fp = fdopen(fd, "w");
+  if (!msg->fp)
   {
     FREE(&msg->path);
     close(fd);
@@ -1668,7 +1676,8 @@ static int _mh_commit_message(struct Context *ctx, struct Message *msg,
     return -1;
   }
 
-  if ((dirp = opendir(ctx->path)) == NULL)
+  dirp = opendir(ctx->path);
+  if (!dirp)
   {
     mutt_perror(ctx->path);
     return -1;
@@ -1753,10 +1762,12 @@ static int mh_rewrite_message(struct Context *ctx, int msgno)
   long old_body_length = h->content->length;
   long old_hdr_lines = h->lines;
 
-  if ((dest = mx_open_new_message(ctx, h, 0)) == NULL)
+  dest = mx_open_new_message(ctx, h, 0);
+  if (!dest)
     return -1;
 
-  if ((rc = mutt_copy_message(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN)) == 0)
+  rc = mutt_copy_message(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);
+  if (rc == 0)
   {
     snprintf(oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
     strfcpy(partpath, h->path, _POSIX_PATH_MAX);
@@ -1792,7 +1803,8 @@ static int mh_rewrite_message(struct Context *ctx, int msgno)
     if (ctx->magic == MUTT_MH && rc == 0)
     {
       snprintf(newpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
-      if ((rc = safe_rename(newpath, oldpath)) == 0)
+      rc = safe_rename(newpath, oldpath);
+      if (rc == 0)
         mutt_str_replace(&h->path, partpath);
     }
   }
@@ -1844,7 +1856,8 @@ static int maildir_sync_message(struct Context *ctx, int msgno)
     char suffix[16];
     char *p = NULL;
 
-    if ((p = strrchr(h->path, '/')) == NULL)
+    p = strrchr(h->path, '/');
+    if (!p)
     {
       mutt_debug(1, "maildir_sync_message: %s: unable to find subdir!\n", h->path);
       return -1;
@@ -1853,7 +1866,8 @@ static int maildir_sync_message(struct Context *ctx, int msgno)
     strfcpy(newpath, p, sizeof(newpath));
 
     /* kill the previous flags */
-    if ((p = strchr(newpath, ':')) != NULL)
+    p = strchr(newpath, ':');
+    if (p)
       *p = '\0';
 
     maildir_flags(suffix, sizeof(suffix), h);
@@ -2421,7 +2435,8 @@ static FILE *_maildir_open_find_message(const char *folder, const char *unique,
 
   snprintf(dir, sizeof(dir), "%s/%s", folder, subfolder);
 
-  if ((dp = opendir(dir)) == NULL)
+  dp = opendir(dir);
+  if (!dp)
   {
     errno = ENOENT;
     return NULL;
@@ -2510,7 +2525,8 @@ int maildir_check_empty(const char *path)
      */
     snprintf(realpath, sizeof(realpath), "%s/%s", path,
              iter == 0 ? "cur" : "new");
-    if ((dp = opendir(realpath)) == NULL)
+    dp = opendir(realpath);
+    if (!dp)
       return -1;
     while ((de = readdir(dp)))
     {
@@ -2540,7 +2556,8 @@ int mh_check_empty(const char *path)
   struct dirent *de = NULL;
   int r = 1; /* assume empty until we find a message */
 
-  if ((dp = opendir(path)) == NULL)
+  dp = opendir(path);
+  if (!dp)
     return -1;
   while ((de = readdir(dp)))
   {
index 0288e201c77ee09196547540ccc6bb043f62e6c1..8985169a7b52a9b0fba11f88f8150653cd9c4303 100644 (file)
@@ -327,7 +327,8 @@ int raw_socket_read(struct Connection *conn, char *buf, size_t len)
   int rc;
 
   mutt_allow_interrupt(1);
-  if ((rc = read(conn->fd, buf, len)) == -1)
+  rc = read(conn->fd, buf, len);
+  if (rc == -1)
   {
     mutt_error(_("Error talking to %s (%s)"), conn->account.host, strerror(errno));
     mutt_sleep(2);
@@ -351,7 +352,8 @@ int raw_socket_write(struct Connection *conn, const char *buf, size_t count)
   int rc;
 
   mutt_allow_interrupt(1);
-  if ((rc = write(conn->fd, buf, count)) == -1)
+  rc = write(conn->fd, buf, count);
+  if (rc == -1)
   {
     mutt_error(_("Error talking to %s (%s)"), conn->account.host, strerror(errno));
     mutt_sleep(2);
@@ -520,7 +522,8 @@ int raw_socket_open(struct Connection *conn)
     fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
     if (fd >= 0)
     {
-      if ((rc = socket_connect(fd, cur->ai_addr)) == 0)
+      rc = socket_connect(fd, cur->ai_addr);
+      if (rc == 0)
       {
         fcntl(fd, F_SETFD, FD_CLOEXEC);
         conn->fd = fd;
@@ -580,7 +583,8 @@ int raw_socket_open(struct Connection *conn)
 
     if (fd >= 0)
     {
-      if ((rc = socket_connect(fd, (struct sockaddr *) &sin)) == 0)
+      rc = socket_connect(fd, (struct sockaddr *) &sin);
+      if (rc == 0)
       {
         fcntl(fd, F_SETFD, FD_CLOEXEC);
         conn->fd = fd;
index 13de32e27ac5c733e15118bb869aca0c74df2786..33362c0be1a0efc72ece0206dc83ae30c319ea88 100644 (file)
@@ -121,7 +121,8 @@ static int ssl_load_certificates(SSL_CTX *ctx)
     SSL_CTX_set_cert_store(ctx, store);
   }
 
-  if ((fp = fopen(CertificateFile, "rt")) == NULL)
+  fp = fopen(CertificateFile, "rt");
+  if (!fp)
     return 0;
 
   while (NULL != PEM_read_X509(fp, &cert, NULL, NULL))
@@ -632,7 +633,8 @@ static int check_certificate_file(X509 *peercert)
   if (!CertificateFile)
     return 0;
 
-  if ((fp = fopen(CertificateFile, "rt")) == NULL)
+  fp = fopen(CertificateFile, "rt");
+  if (!fp)
     return 0;
 
   if (!X509_digest(peercert, EVP_sha256(), peermd, &peermdlen))
@@ -1074,7 +1076,8 @@ static int ssl_negotiate(struct Connection *conn, struct SslSockData *ssldata)
   int err;
   const char *errmsg = NULL;
 
-  if ((HostExDataIndex = SSL_get_ex_new_index(0, "host", NULL, NULL, NULL)) == -1)
+  HostExDataIndex = SSL_get_ex_new_index(0, "host", NULL, NULL, NULL);
+  if (HostExDataIndex == -1)
   {
     mutt_debug(1, "failed to get index for application specific data\n");
     return -1;
@@ -1086,7 +1089,8 @@ static int ssl_negotiate(struct Connection *conn, struct SslSockData *ssldata)
     return -1;
   }
 
-  if ((SkipModeExDataIndex = SSL_get_ex_new_index(0, "skip", NULL, NULL, NULL)) == -1)
+  SkipModeExDataIndex = SSL_get_ex_new_index(0, "skip", NULL, NULL, NULL);
+  if (SkipModeExDataIndex == -1)
   {
     mutt_debug(1, "failed to get index for application specific data\n");
     return -1;
@@ -1112,7 +1116,8 @@ static int ssl_negotiate(struct Connection *conn, struct SslSockData *ssldata)
 
   ERR_clear_error();
 
-  if ((err = SSL_connect(ssldata->ssl)) != 1)
+  err = SSL_connect(ssldata->ssl);
+  if (err != 1)
   {
     switch (SSL_get_error(ssldata->ssl, err))
     {
index e7994072d0d220c34a1a505ba543f3f07ca9c752..e666ec2a6e062466402ebe1623d031104640af2e 100644 (file)
@@ -61,13 +61,15 @@ static int tunnel_socket_open(struct Connection *conn)
 
   mutt_message(_("Connecting with \"%s\"..."), Tunnel);
 
-  if ((rc = pipe(pin)) == -1)
+  rc = pipe(pin);
+  if (rc == -1)
   {
     mutt_perror("pipe");
     FREE(&conn->sockdata);
     return -1;
   }
-  if ((rc = pipe(pout)) == -1)
+  rc = pipe(pout);
+  if (rc == -1)
   {
     mutt_perror("pipe");
     close(pin[0]);
@@ -77,7 +79,8 @@ static int tunnel_socket_open(struct Connection *conn)
   }
 
   mutt_block_signals_system();
-  if ((pid = fork()) == 0)
+  pid = fork();
+  if (pid == 0)
   {
     mutt_unblock_signals_system(0);
     devnull = open("/dev/null", O_RDWR);
index cedd6635da57e29c4db45b4978602ac98a937a4d..f9eb0c951223f70c9bf62a540c8cae189dc7e7ff 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -110,7 +110,8 @@ void mutt_adv_mktemp(char *s, size_t l)
     if (lstat(s, &sb) == -1 && errno == ENOENT)
       return;
 
-    if ((suffix = strrchr(prefix, '.')) != NULL)
+    suffix = strrchr(prefix, '.');
+    if (suffix)
     {
       *suffix = 0;
       suffix++;
@@ -1012,7 +1013,8 @@ void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols,
       col -= wlen; /* reset to passed in value */
       wptr = dest; /* reset write ptr */
       wlen = ((flags & MUTT_FORMAT_ARROWCURSOR) && option(OPT_ARROW_CURSOR)) ? 3 : 0;
-      if ((pid = mutt_create_filter(command->data, NULL, &filter, NULL)) != -1)
+      pid = mutt_create_filter(command->data, NULL, &filter, NULL);
+      if (pid != -1)
       {
         int rc;
 
@@ -1495,7 +1497,8 @@ int mutt_save_confirm(const char *s, struct stat *st)
     if (option(OPT_CONFIRMAPPEND))
     {
       snprintf(tmp, sizeof(tmp), _("Append messages to %s?"), s);
-      if ((rc = mutt_yesorno(tmp, MUTT_YES)) == MUTT_NO)
+      rc = mutt_yesorno(tmp, MUTT_YES);
+      if (rc == MUTT_NO)
         ret = 1;
       else if (rc == MUTT_ABORT)
         ret = -1;
@@ -1529,7 +1532,8 @@ int mutt_save_confirm(const char *s, struct stat *st)
       if (option(OPT_CONFIRMCREATE))
       {
         snprintf(tmp, sizeof(tmp), _("Create %s?"), s);
-        if ((rc = mutt_yesorno(tmp, MUTT_YES)) == MUTT_NO)
+        rc = mutt_yesorno(tmp, MUTT_YES);
+        if (rc == MUTT_NO)
           ret = 1;
         else if (rc == MUTT_ABORT)
           ret = -1;
diff --git a/mx.c b/mx.c
index a0dbdc6232694137abe3090d249a996b4aec5d5a..3406a07128ce30e20f0d0c4564e235cae4f3deb3 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -710,7 +710,8 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint)
     {
       mutt_expand_path(mbox, sizeof(mbox));
       snprintf(buf, sizeof(buf), _("Move read messages to %s?"), mbox);
-      if ((move_messages = query_quadoption(OPT_MOVE, buf)) == MUTT_ABORT)
+      move_messages = query_quadoption(OPT_MOVE, buf);
+      if (move_messages == MUTT_ABORT)
       {
         ctx->closing = false;
         return -1;
@@ -728,7 +729,8 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint)
              ctx->deleted == 1 ? _("Purge %d deleted message?") :
                                  _("Purge %d deleted messages?"),
              ctx->deleted);
-    if ((purge = query_quadoption(OPT_DELETE, buf)) == MUTT_ABORT)
+    purge = query_quadoption(OPT_DELETE, buf);
+    if (purge == MUTT_ABORT)
     {
       ctx->closing = false;
       return -1;
@@ -828,7 +830,8 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint)
   /* allow IMAP to preserve the deleted flag across sessions */
   if (ctx->magic == MUTT_IMAP)
   {
-    if ((check = imap_sync_mailbox(ctx, purge)) != 0)
+    check = imap_sync_mailbox(ctx, purge);
+    if (check != 0)
     {
       ctx->closing = false;
       return check;
@@ -849,7 +852,8 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint)
 
     if (ctx->changed || ctx->deleted)
     {
-      if ((check = sync_mailbox(ctx, index_hint)) != 0)
+      check = sync_mailbox(ctx, index_hint);
+      if (check != 0)
       {
         ctx->closing = false;
         return check;
@@ -1023,7 +1027,8 @@ int mx_sync_mailbox(struct Context *ctx, int *index_hint)
              ctx->deleted == 1 ? _("Purge %d deleted message?") :
                                  _("Purge %d deleted messages?"),
              ctx->deleted);
-    if ((purge = query_quadoption(OPT_DELETE, buf)) == MUTT_ABORT)
+    purge = query_quadoption(OPT_DELETE, buf);
+    if (purge == MUTT_ABORT)
       return -1;
     else if (purge == MUTT_NO)
     {
index 252adea6135cc292299d0d1e59856c40da788f3d..e3fd0356e534c1aae68d80305f559514af63faa1 100644 (file)
@@ -625,7 +625,8 @@ int crypt_write_signed(struct Body *a, struct State *s, const char *tempfile)
   hadcr = false;
   while (bytes > 0)
   {
-    if ((c = fgetc(s->fpin)) == EOF)
+    c = fgetc(s->fpin);
+    if (c == EOF)
       break;
 
     bytes--;
@@ -840,7 +841,8 @@ int crypt_get_keys(struct Header *msg, char **keylist, int oppenc_mode)
   {
     if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
     {
-      if ((*keylist = crypt_pgp_findkeys(adrlist, oppenc_mode)) == NULL)
+      *keylist = crypt_pgp_findkeys(adrlist, oppenc_mode);
+      if (!*keylist)
       {
         rfc822_free_address(&adrlist);
         return -1;
@@ -851,7 +853,8 @@ int crypt_get_keys(struct Header *msg, char **keylist, int oppenc_mode)
     }
     if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME))
     {
-      if ((*keylist = crypt_smime_findkeys(adrlist, oppenc_mode)) == NULL)
+      *keylist = crypt_smime_findkeys(adrlist, oppenc_mode);
+      if (!*keylist)
       {
         rfc822_free_address(&adrlist);
         return -1;
index bf7c4329fce00b3dec6b8a1fcac712a7b8925bc2..3f229216057a6506d6892ec2653456d9f01284c4 100644 (file)
@@ -648,7 +648,8 @@ static char *data_object_to_tempfile(gpgme_data_t data, char *tempf, FILE **ret_
     mutt_mktemp(tempfb, sizeof(tempfb));
     tempf = tempfb;
   }
-  if ((fp = safe_fopen(tempf, tempf == tempfb ? "w+" : "a+")) == NULL)
+  fp = safe_fopen(tempf, tempf == tempfb ? "w+" : "a+");
+  if (!fp)
   {
     mutt_perror(_("Can't create temporary file"));
     return NULL;
@@ -1961,7 +1962,8 @@ int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body
     saved_length = b->length;
 
     mutt_mktemp(tempfile, sizeof(tempfile));
-    if ((decoded_fp = safe_fopen(tempfile, "w+")) == NULL)
+    decoded_fp = safe_fopen(tempfile, "w+");
+    if (!decoded_fp)
     {
       mutt_perror(tempfile);
       return -1;
@@ -1990,7 +1992,8 @@ int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body
   }
   unlink(tempfile);
 
-  if ((*cur = decrypt_part(b, &s, *fpout, 0, &is_signed)) == NULL)
+  *cur = decrypt_part(b, &s, *fpout, 0, &is_signed);
+  if (!*cur)
     rv = -1;
   rewind(*fpout);
   if (is_signed > 0)
@@ -2155,7 +2158,8 @@ static int pgp_gpgme_extract_keys(gpgme_data_t keydata, FILE **fp, int dryrun)
   int rc = -1;
   time_t tt;
 
-  if ((err = gpgme_new(&tmpctx)) != GPG_ERR_NO_ERROR)
+  err = gpgme_new(&tmpctx);
+  if (err != GPG_ERR_NO_ERROR)
   {
     mutt_debug(1, "Error creating GPGME context\n");
     return rc;
@@ -2188,7 +2192,8 @@ static int pgp_gpgme_extract_keys(gpgme_data_t keydata, FILE **fp, int dryrun)
     }
   }
 
-  if ((err = gpgme_op_import(tmpctx, keydata)) != GPG_ERR_NO_ERROR)
+  err = gpgme_op_import(tmpctx, keydata);
+  if (err != GPG_ERR_NO_ERROR)
   {
     mutt_debug(1, "Error importing key\n");
     goto err_tmpdir;
@@ -2302,7 +2307,8 @@ static int pgp_check_traditional_one_body(FILE *fp, struct Body *b)
     return 0;
   }
 
-  if ((tfp = fopen(tempfile, "r")) == NULL)
+  tfp = fopen(tempfile, "r");
+  if (!tfp)
   {
     unlink(tempfile);
     return 0;
@@ -2372,7 +2378,8 @@ void pgp_gpgme_invoke_import(const char *fname)
   /* Note that the stream, "in", needs to be kept open while the keydata
    * is used.
    */
-  if ((err = gpgme_data_new_from_stream(&keydata, in)) != GPG_ERR_NO_ERROR)
+  err = gpgme_data_new_from_stream(&keydata, in);
+  if (err != GPG_ERR_NO_ERROR)
   {
     safe_fclose(&in);
     mutt_error(_("error allocating data object: %s\n"), gpgme_strerror(err));
@@ -4076,7 +4083,8 @@ static void crypt_add_string_to_hints(struct ListHead *hints, const char *str)
   char *scratch = NULL;
   char *t = NULL;
 
-  if ((scratch = safe_strdup(str)) == NULL)
+  scratch = safe_strdup(str);
+  if (!scratch)
     return;
 
   for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
index 3b4e8dd0faeac8f3a0d44192eac4ee0f39dbecd1..62a41dcb464c8b8671cda7d0d212101c9c81152c 100644 (file)
@@ -390,7 +390,8 @@ struct PgpKeyInfo *pgp_get_candidates(enum PgpRing keyring, struct ListHead *hin
   int is_sub;
   int devnull;
 
-  if ((devnull = open("/dev/null", O_RDWR)) == -1)
+  devnull = open("/dev/null", O_RDWR);
+  if (devnull == -1)
     return NULL;
 
   mutt_str_replace(&_chs, Charset);
index b86f1ef6f67b6a1ca948f71817cc568f77c29507..19f7d150b941adec2de23b126ff78a94dcd853d5 100644 (file)
@@ -394,7 +394,8 @@ int pgp_application_pgp_handler(struct Body *m, struct State *s)
 
       /* Copy PGP material to temporary file */
       mutt_mktemp(tmpfname, sizeof(tmpfname));
-      if ((tmpfp = safe_fopen(tmpfname, "w+")) == NULL)
+      tmpfp = safe_fopen(tmpfname, "w+");
+      if (!tmpfp)
       {
         mutt_perror(tmpfname);
         FREE(&gpgcharset);
@@ -434,7 +435,8 @@ int pgp_application_pgp_handler(struct Body *m, struct State *s)
       if (!clearsign || (s->flags & MUTT_VERIFY))
       {
         mutt_mktemp(outfile, sizeof(outfile));
-        if ((pgpout = safe_fopen(outfile, "w+")) == NULL)
+        pgpout = safe_fopen(outfile, "w+");
+        if (!pgpout)
         {
           mutt_perror(outfile);
           safe_fclose(&tmpfp);
@@ -640,7 +642,8 @@ static int pgp_check_traditional_one_body(FILE *fp, struct Body *b)
     return 0;
   }
 
-  if ((tfp = fopen(tempfile, "r")) == NULL)
+  tfp = fopen(tempfile, "r");
+  if (!tfp)
   {
     unlink(tempfile);
     return 0;
@@ -832,7 +835,8 @@ static struct Body *pgp_decrypt_part(struct Body *a, struct State *s,
   int rv;
 
   mutt_mktemp(pgperrfile, sizeof(pgperrfile));
-  if ((pgperr = safe_fopen(pgperrfile, "w+")) == NULL)
+  pgperr = safe_fopen(pgperrfile, "w+");
+  if (!pgperr)
   {
     mutt_perror(pgperrfile);
     return NULL;
@@ -840,7 +844,8 @@ static struct Body *pgp_decrypt_part(struct Body *a, struct State *s,
   unlink(pgperrfile);
 
   mutt_mktemp(pgptmpfile, sizeof(pgptmpfile));
-  if ((pgptmp = safe_fopen(pgptmpfile, "w")) == NULL)
+  pgptmp = safe_fopen(pgptmpfile, "w");
+  if (!pgptmp)
   {
     mutt_perror(pgptmpfile);
     safe_fclose(&pgperr);
@@ -925,7 +930,8 @@ static struct Body *pgp_decrypt_part(struct Body *a, struct State *s,
 
   rewind(fpout);
 
-  if ((tattach = mutt_read_mime_header(fpout, 0)) != NULL)
+  tattach = mutt_read_mime_header(fpout, 0);
+  if (tattach)
   {
     /*
      * Need to set the length of this body part.
@@ -973,7 +979,8 @@ int pgp_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur
     saved_length = b->length;
 
     mutt_mktemp(tempfile, sizeof(tempfile));
-    if ((decoded_fp = safe_fopen(tempfile, "w+")) == NULL)
+    decoded_fp = safe_fopen(tempfile, "w+");
+    if (!decoded_fp)
     {
       mutt_perror(tempfile);
       return -1;
@@ -994,7 +1001,8 @@ int pgp_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur
   }
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((*fpout = safe_fopen(tempfile, "w+")) == NULL)
+  *fpout = safe_fopen(tempfile, "w+");
+  if (!*fpout)
   {
     mutt_perror(tempfile);
     rv = -1;
@@ -1002,7 +1010,8 @@ int pgp_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur
   }
   unlink(tempfile);
 
-  if ((*cur = pgp_decrypt_part(b, &s, *fpout, p)) == NULL)
+  *cur = pgp_decrypt_part(b, &s, *fpout, p);
+  if (!*cur)
     rv = -1;
   rewind(*fpout);
 
@@ -1032,7 +1041,8 @@ int pgp_encrypted_handler(struct Body *a, struct State *s)
   int rc = 0;
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((fpout = safe_fopen(tempfile, "w+")) == NULL)
+  fpout = safe_fopen(tempfile, "w+");
+  if (!fpout)
   {
     if (s->flags & MUTT_DISPLAY)
       state_attach_puts(_("[-- Error: could not create temporary file! --]\n"), s);
@@ -1042,7 +1052,8 @@ int pgp_encrypted_handler(struct Body *a, struct State *s)
   if (s->flags & MUTT_DISPLAY)
     crypt_current_time(s, "PGP");
 
-  if ((tattach = pgp_decrypt_part(a, s, fpout, a)) != NULL)
+  tattach = pgp_decrypt_part(a, s, fpout, a);
+  if (tattach)
   {
     if (s->flags & MUTT_DISPLAY)
       state_attach_puts(
@@ -1105,13 +1116,15 @@ struct Body *pgp_sign_message(struct Body *a)
   convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
 
   mutt_mktemp(sigfile, sizeof(sigfile));
-  if ((fp = safe_fopen(sigfile, "w")) == NULL)
+  fp = safe_fopen(sigfile, "w");
+  if (!fp)
   {
     return NULL;
   }
 
   mutt_mktemp(signedfile, sizeof(signedfile));
-  if ((sfp = safe_fopen(signedfile, "w")) == NULL)
+  sfp = safe_fopen(signedfile, "w");
+  if (!sfp)
   {
     mutt_perror(signedfile);
     safe_fclose(&fp);
@@ -1124,7 +1137,8 @@ struct Body *pgp_sign_message(struct Body *a)
   mutt_write_mime_body(a, sfp);
   safe_fclose(&sfp);
 
-  if ((thepid = pgp_invoke_sign(&pgpin, &pgpout, &pgperr, -1, -1, -1, signedfile)) == -1)
+  thepid = pgp_invoke_sign(&pgpin, &pgpout, &pgperr, -1, -1, -1, signedfile);
+  if (thepid == -1)
   {
     mutt_perror(_("Can't open PGP subprocess!"));
     safe_fclose(&fp);
@@ -1353,14 +1367,16 @@ struct Body *pgp_encrypt_message(struct Body *a, char *keylist, int sign)
   pid_t thepid;
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((fpout = safe_fopen(tempfile, "w+")) == NULL)
+  fpout = safe_fopen(tempfile, "w+");
+  if (!fpout)
   {
     mutt_perror(tempfile);
     return NULL;
   }
 
   mutt_mktemp(pgperrfile, sizeof(pgperrfile));
-  if ((pgperr = safe_fopen(pgperrfile, "w+")) == NULL)
+  pgperr = safe_fopen(pgperrfile, "w+");
+  if (!pgperr)
   {
     mutt_perror(pgperrfile);
     unlink(tempfile);
@@ -1370,7 +1386,8 @@ struct Body *pgp_encrypt_message(struct Body *a, char *keylist, int sign)
   unlink(pgperrfile);
 
   mutt_mktemp(pgpinfile, sizeof(pgpinfile));
-  if ((fptmp = safe_fopen(pgpinfile, "w")) == NULL)
+  fptmp = safe_fopen(pgpinfile, "w");
+  if (!fptmp)
   {
     mutt_perror(pgpinfile);
     unlink(tempfile);
@@ -1492,14 +1509,16 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis
   if (mutt_strcasecmp(a->subtype, "plain") != 0)
     return NULL;
 
-  if ((fp = fopen(a->filename, "r")) == NULL)
+  fp = fopen(a->filename, "r");
+  if (!fp)
   {
     mutt_perror(a->filename);
     return NULL;
   }
 
   mutt_mktemp(pgpinfile, sizeof(pgpinfile));
-  if ((pgpin = safe_fopen(pgpinfile, "w")) == NULL)
+  pgpin = safe_fopen(pgpinfile, "w");
+  if (!pgpin)
   {
     mutt_perror(pgpinfile);
     safe_fclose(&fp);
index f16d714575e290a0a406e79246414a835818ce1b..c7a3d45c33aeb35f89c5f555fbffbed4c57e6264 100644 (file)
@@ -556,12 +556,14 @@ static struct PgpKeyInfo *pgp_select_key(struct PgpKeyInfo *keys,
       case OP_VERIFY_KEY:
 
         mutt_mktemp(tempfile, sizeof(tempfile));
-        if ((devnull = fopen("/dev/null", "w")) == NULL)
+        devnull = fopen("/dev/null", "w");
+        if (!devnull)
         {
           mutt_perror(_("Can't open /dev/null"));
           break;
         }
-        if ((fp = safe_fopen(tempfile, "w")) == NULL)
+        fp = safe_fopen(tempfile, "w");
+        if (!fp)
         {
           safe_fclose(&devnull);
           mutt_perror(_("Can't create temporary file"));
@@ -737,13 +739,15 @@ struct Body *pgp_make_key_attachment(char *tempf)
     tempf = tempfb;
   }
 
-  if ((tempfp = safe_fopen(tempf, tempf == tempfb ? "w" : "a")) == NULL)
+  tempfp = safe_fopen(tempf, tempf == tempfb ? "w" : "a");
+  if (!tempfp)
   {
     mutt_perror(_("Can't create temporary file"));
     return NULL;
   }
 
-  if ((devnull = fopen("/dev/null", "w")) == NULL)
+  devnull = fopen("/dev/null", "w");
+  if (!devnull)
   {
     mutt_perror(_("Can't open /dev/null"));
     safe_fclose(&tempfp);
@@ -790,7 +794,8 @@ static void pgp_add_string_to_hints(struct ListHead *hints, const char *str)
   char *scratch = NULL;
   char *t = NULL;
 
-  if ((scratch = safe_strdup(str)) == NULL)
+  scratch = safe_strdup(str);
+  if (!scratch)
     return;
 
   for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
index b10edfbd87a7b0944a91cffee24a41fe901f2b8b..4a101c7958e7bf25f07c61b0bd54a15808250ad1 100644 (file)
@@ -164,14 +164,16 @@ static short pgp_find_hash(const char *fname)
   short rv = -1;
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((out = safe_fopen(tempfile, "w+")) == NULL)
+  out = safe_fopen(tempfile, "w+");
+  if (!out)
   {
     mutt_perror(tempfile);
     goto bye;
   }
   unlink(tempfile);
 
-  if ((in = fopen(fname, "r")) == NULL)
+  in = fopen(fname, "r");
+  if (!in)
   {
     mutt_perror(fname);
     goto bye;
@@ -180,7 +182,8 @@ static short pgp_find_hash(const char *fname)
   pgp_dearmor(in, out);
   rewind(out);
 
-  if ((p = pgp_read_packet(out, &l)) != NULL)
+  p = pgp_read_packet(out, &l);
+  if (p)
   {
     rv = pgp_mic_from_packet(p, l);
   }
index 408b981cc518e2588365a56771dc6064e8635eb3..6c4ddd18c95f314ceacc3051b504413af82ba819 100644 (file)
@@ -575,7 +575,8 @@ static struct SmimeKey *smime_get_candidates(char *search, short public)
   snprintf(index_file, sizeof(index_file), "%s/.index",
            public ? NONULL(SmimeCertificates) : NONULL(SmimeKeys));
 
-  if ((fp = safe_fopen(index_file, "r")) == NULL)
+  fp = safe_fopen(index_file, "r");
+  if (!fp)
   {
     mutt_perror(index_file);
     return NULL;
@@ -911,7 +912,8 @@ static int smime_handle_cert_email(char *certificate, char *mailbox, int copy,
   size_t len = 0;
 
   mutt_mktemp(tmpfname, sizeof(tmpfname));
-  if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+  fperr = safe_fopen(tmpfname, "w+");
+  if (!fperr)
   {
     mutt_perror(tmpfname);
     return 1;
@@ -919,7 +921,8 @@ static int smime_handle_cert_email(char *certificate, char *mailbox, int copy,
   mutt_unlink(tmpfname);
 
   mutt_mktemp(tmpfname, sizeof(tmpfname));
-  if ((fpout = safe_fopen(tmpfname, "w+")) == NULL)
+  fpout = safe_fopen(tmpfname, "w+");
+  if (!fpout)
   {
     safe_fclose(&fperr);
     mutt_perror(tmpfname);
@@ -1003,7 +1006,8 @@ static char *smime_extract_certificate(char *infile)
   int empty;
 
   mutt_mktemp(tmpfname, sizeof(tmpfname));
-  if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+  fperr = safe_fopen(tmpfname, "w+");
+  if (!fperr)
   {
     mutt_perror(tmpfname);
     return NULL;
@@ -1011,7 +1015,8 @@ static char *smime_extract_certificate(char *infile)
   mutt_unlink(tmpfname);
 
   mutt_mktemp(pk7out, sizeof(pk7out));
-  if ((fpout = safe_fopen(pk7out, "w+")) == NULL)
+  fpout = safe_fopen(pk7out, "w+");
+  if (!fpout)
   {
     safe_fclose(&fperr);
     mutt_perror(pk7out);
@@ -1050,7 +1055,8 @@ static char *smime_extract_certificate(char *infile)
 
   safe_fclose(&fpout);
   mutt_mktemp(certfile, sizeof(certfile));
-  if ((fpout = safe_fopen(certfile, "w+")) == NULL)
+  fpout = safe_fopen(certfile, "w+");
+  if (!fpout)
   {
     safe_fclose(&fperr);
     mutt_unlink(pk7out);
@@ -1104,7 +1110,8 @@ static char *smime_extract_signer_certificate(char *infile)
   int empty;
 
   mutt_mktemp(tmpfname, sizeof(tmpfname));
-  if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+  fperr = safe_fopen(tmpfname, "w+");
+  if (!fperr)
   {
     mutt_perror(tmpfname);
     return NULL;
@@ -1112,7 +1119,8 @@ static char *smime_extract_signer_certificate(char *infile)
   mutt_unlink(tmpfname);
 
   mutt_mktemp(certfile, sizeof(certfile));
-  if ((fpout = safe_fopen(certfile, "w+")) == NULL)
+  fpout = safe_fopen(certfile, "w+");
+  if (!fpout)
   {
     safe_fclose(&fperr);
     mutt_perror(certfile);
@@ -1166,7 +1174,8 @@ void smime_invoke_import(char *infile, char *mailbox)
   pid_t thepid = -1;
 
   mutt_mktemp(tmpfname, sizeof(tmpfname));
-  if ((fperr = safe_fopen(tmpfname, "w+")) == NULL)
+  fperr = safe_fopen(tmpfname, "w+");
+  if (!fperr)
   {
     mutt_perror(tmpfname);
     return;
@@ -1174,7 +1183,8 @@ void smime_invoke_import(char *infile, char *mailbox)
   mutt_unlink(tmpfname);
 
   mutt_mktemp(tmpfname, sizeof(tmpfname));
-  if ((fpout = safe_fopen(tmpfname, "w+")) == NULL)
+  fpout = safe_fopen(tmpfname, "w+");
+  if (!fpout)
   {
     safe_fclose(&fperr);
     mutt_perror(tmpfname);
@@ -1319,14 +1329,16 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist)
   pid_t thepid;
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((fpout = safe_fopen(tempfile, "w+")) == NULL)
+  fpout = safe_fopen(tempfile, "w+");
+  if (!fpout)
   {
     mutt_perror(tempfile);
     return NULL;
   }
 
   mutt_mktemp(smimeerrfile, sizeof(smimeerrfile));
-  if ((smimeerr = safe_fopen(smimeerrfile, "w+")) == NULL)
+  smimeerr = safe_fopen(smimeerrfile, "w+");
+  if (!smimeerr)
   {
     mutt_perror(smimeerrfile);
     safe_fclose(&fpout);
@@ -1336,7 +1348,8 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist)
   mutt_unlink(smimeerrfile);
 
   mutt_mktemp(smimeinfile, sizeof(smimeinfile));
-  if ((fptmp = safe_fopen(smimeinfile, "w+")) == NULL)
+  fptmp = safe_fopen(smimeinfile, "w+");
+  if (!fptmp)
   {
     mutt_perror(smimeinfile);
     mutt_unlink(tempfile);
@@ -1478,14 +1491,16 @@ struct Body *smime_sign_message(struct Body *a)
   convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
 
   mutt_mktemp(filetosign, sizeof(filetosign));
-  if ((sfp = safe_fopen(filetosign, "w+")) == NULL)
+  sfp = safe_fopen(filetosign, "w+");
+  if (!sfp)
   {
     mutt_perror(filetosign);
     return NULL;
   }
 
   mutt_mktemp(signedfile, sizeof(signedfile));
-  if ((smimeout = safe_fopen(signedfile, "w+")) == NULL)
+  smimeout = safe_fopen(signedfile, "w+");
+  if (!smimeout)
   {
     mutt_perror(signedfile);
     safe_fclose(&sfp);
@@ -1627,7 +1642,8 @@ int smime_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile)
 
   /* decode to a tempfile, saving the original destination */
   fp = s->fpout;
-  if ((s->fpout = safe_fopen(signedfile, "w")) == NULL)
+  s->fpout = safe_fopen(signedfile, "w");
+  if (!s->fpout)
   {
     mutt_perror(signedfile);
     return -1;
@@ -1739,14 +1755,16 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o
     return NULL;
 
   mutt_mktemp(outfile, sizeof(outfile));
-  if ((smimeout = safe_fopen(outfile, "w+")) == NULL)
+  smimeout = safe_fopen(outfile, "w+");
+  if (!smimeout)
   {
     mutt_perror(outfile);
     return NULL;
   }
 
   mutt_mktemp(errfile, sizeof(errfile));
-  if ((smimeerr = safe_fopen(errfile, "w+")) == NULL)
+  smimeerr = safe_fopen(errfile, "w+");
+  if (!smimeerr)
   {
     mutt_perror(errfile);
     safe_fclose(&smimeout);
@@ -1755,7 +1773,8 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o
   mutt_unlink(errfile);
 
   mutt_mktemp(tmpfname, sizeof(tmpfname));
-  if ((tmpfp = safe_fopen(tmpfname, "w+")) == NULL)
+  tmpfp = safe_fopen(tmpfname, "w+");
+  if (!tmpfp)
   {
     mutt_perror(tmpfname);
     safe_fclose(&smimeout);
@@ -1813,7 +1832,8 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o
     fflush(smimeerr);
     rewind(smimeerr);
 
-    if ((c = fgetc(smimeerr)) != EOF)
+    c = fgetc(smimeerr);
+    if (c != EOF)
     {
       ungetc(c, smimeerr);
 
@@ -1840,7 +1860,8 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o
     else
     {
       mutt_mktemp(tmptmpfname, sizeof(tmptmpfname));
-      if ((fpout = safe_fopen(tmptmpfname, "w+")) == NULL)
+      fpout = safe_fopen(tmptmpfname, "w+");
+      if (!fpout)
       {
         mutt_perror(tmptmpfname);
         safe_fclose(&smimeout);
@@ -1861,7 +1882,8 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o
     fflush(fpout);
     rewind(fpout);
 
-    if ((p = mutt_read_mime_header(fpout, 0)) != NULL)
+    p = mutt_read_mime_header(fpout, 0);
+    if (p)
     {
       fstat(fileno(fpout), &info);
       p->length = info.st_size - p->offset;
@@ -1940,7 +1962,8 @@ int smime_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **c
   fseeko(s.fpin, b->offset, SEEK_SET);
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((tmpfp = safe_fopen(tempfile, "w+")) == NULL)
+  tmpfp = safe_fopen(tempfile, "w+");
+  if (!tmpfp)
   {
     mutt_perror(tempfile);
     return -1;
@@ -1957,7 +1980,8 @@ int smime_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **c
   s.fpout = 0;
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((*fpout = safe_fopen(tempfile, "w+")) == NULL)
+  *fpout = safe_fopen(tempfile, "w+");
+  if (!*fpout)
   {
     mutt_perror(tempfile);
     rv = -1;
diff --git a/pager.c b/pager.c
index 2b496590baa69a7e01cc1dc8dbf4a4b4643c5fc0..2f2e821cbad689e3d7d82380fc3d34c0f9c8927c 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1154,7 +1154,8 @@ static int fill_buffer(FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char *
   {
     if (offset != *last_pos)
       fseeko(f, offset, SEEK_SET);
-    if ((*buf = (unsigned char *) mutt_read_line((char *) *buf, blen, f, &l, MUTT_EOL)) == NULL)
+    *buf = (unsigned char *) mutt_read_line((char *) *buf, blen, f, &l, MUTT_EOL);
+    if (!*buf)
     {
       fmt[0] = 0;
       return -1;
@@ -2063,7 +2064,8 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
   rd.searchbuf = searchbuf;
   rd.has_types = (IsHeader(extra) || (flags & MUTT_SHOWCOLOR)) ? MUTT_TYPES : 0; /* main message or rfc822 attachment */
 
-  if ((rd.fp = fopen(fname, "r")) == NULL)
+  rd.fp = fopen(fname, "r");
+  if (!rd.fp)
   {
     mutt_perror(fname);
     return -1;
diff --git a/parse.c b/parse.c
index d23a509629250f70237b283a6d67c824001261b5..080c676c2b54b880d7d2a9fba497c7d324f986ce 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -159,7 +159,8 @@ static struct Parameter *parse_parameters(const char *s)
 
   while (*s)
   {
-    if ((p = strpbrk(s, "=;")) == NULL)
+    p = strpbrk(s, "=;");
+    if (!p)
     {
       mutt_debug(1, "parse_parameters: malformed parameter: %s\n", s);
       goto bail;
@@ -310,7 +311,8 @@ void mutt_parse_content_type(char *s, struct Body *ct)
   mutt_free_parameter(&ct->parameter);
 
   /* First extract any existing parameters */
-  if ((pc = strchr(s, ';')) != NULL)
+  pc = strchr(s, ';');
+  if (pc)
   {
     *pc++ = 0;
     while (*pc && ISSPACE(*pc))
@@ -400,7 +402,8 @@ static void parse_content_disposition(const char *s, struct Body *ct)
     ct->disposition = DISPATTACH;
 
   /* Check to see if a default filename was given */
-  if ((s = strchr(s, ';')) != NULL)
+  s = strchr(s, ';');
+  if (s)
   {
     s = skip_email_wsp(s + 1);
     if ((s = mutt_get_parameter("filename", (parms = parse_parameters(s)))))
@@ -1297,7 +1300,8 @@ struct Address *mutt_parse_adrlist(struct Address *p, const char *s)
   const char *q = NULL;
 
   /* check for a simple whitespace separated list of addresses */
-  if ((q = strpbrk(s, "\"<>():;,\\")) == NULL)
+  q = strpbrk(s, "\"<>():;,\\");
+  if (!q)
   {
     char tmp[HUGE_STRING];
     char *r = NULL;
index 2aa06eb95bcc8b3d48e42b8b84b2598c27668819..9842618cba767068bf45f71406639e18d9755be4 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -484,7 +484,8 @@ static bool eat_date(struct Pattern *pat, struct Buffer *s, struct Buffer *err)
     if (isdigit((unsigned char) *pc))
     {
       /* minimum date specified */
-      if ((pc = get_date(pc, &min, err)) == NULL)
+      pc = get_date(pc, &min, err);
+      if (!pc)
       {
         FREE(&buffer.data);
         return false;
@@ -940,7 +941,8 @@ static int msg_search(struct Context *ctx, struct Pattern *pat, int msgno)
   struct stat st;
 #endif
 
-  if ((msg = mx_open_message(ctx, msgno)) != NULL)
+  msg = mx_open_message(ctx, msgno);
+  if (msg)
   {
     if (option(OPT_THOROUGH_SEARCH))
     {
@@ -957,7 +959,8 @@ static int msg_search(struct Context *ctx, struct Pattern *pat, int msgno)
       }
 #else
       mutt_mktemp(tempfile, sizeof(tempfile));
-      if ((s.fpout = safe_fopen(tempfile, "w+")) == NULL)
+      s.fpout = safe_fopen(tempfile, "w+");
+      if (!s.fpout)
       {
         mutt_perror(tempfile);
         return 0;
@@ -1235,7 +1238,8 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer
           isalias = false;
           /* compile the sub-expression */
           buf = mutt_substrdup(ps.dptr + 1, p);
-          if ((tmp2 = mutt_pattern_comp(buf, flags, err)) == NULL)
+          tmp2 = mutt_pattern_comp(buf, flags, err);
+          if (!tmp2)
           {
             FREE(&buf);
             mutt_pattern_free(&curlist);
@@ -1274,7 +1278,8 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer
         last = tmp;
 
         ps.dptr++; /* move past the ~ */
-        if ((entry = lookup_tag(*ps.dptr)) == NULL)
+        entry = lookup_tag(*ps.dptr);
+        if (!entry)
         {
           snprintf(err->data, err->dsize, _("%c: invalid pattern modifier"), *ps.dptr);
           mutt_pattern_free(&curlist);
@@ -1317,7 +1322,8 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer
         }
         /* compile the sub-expression */
         buf = mutt_substrdup(ps.dptr + 1, p);
-        if ((tmp = mutt_pattern_comp(buf, flags, err)) == NULL)
+        tmp = mutt_pattern_comp(buf, flags, err);
+        if (!tmp)
         {
           FREE(&buf);
           mutt_pattern_free(&curlist);
@@ -1895,7 +1901,8 @@ int mutt_pattern_func(int op, char *prompt)
   mutt_buffer_init(&err);
   err.dsize = STRING;
   err.data = safe_malloc(err.dsize);
-  if ((pat = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err)) == NULL)
+  pat = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err);
+  if (!pat)
   {
     FREE(&simple);
     mutt_error("%s", err.data);
@@ -2029,7 +2036,8 @@ int mutt_search_command(int cur, int op)
       mutt_pattern_free(&SearchPattern);
       err.dsize = STRING;
       err.data = safe_malloc(err.dsize);
-      if ((SearchPattern = mutt_pattern_comp(temp, MUTT_FULL_MSG, &err)) == NULL)
+      SearchPattern = mutt_pattern_comp(temp, MUTT_FULL_MSG, &err);
+      if (!SearchPattern)
       {
         mutt_error("%s", err.data);
         FREE(&err.data);
index 3272ad0d614960675a90bb18425758a24a321ab5..d087e7bfa90630904b1f006df4f899c4fdd9ea48 100644 (file)
@@ -768,7 +768,8 @@ static void pgpring_find_candidates(char *ringfile, const char *hints[], int nhi
 
   short err = 0;
 
-  if ((rfp = fopen(ringfile, "r")) == NULL)
+  rfp = fopen(ringfile, "r");
+  if (!rfp)
   {
     char *error_buf = NULL;
     size_t error_buf_len;
@@ -810,7 +811,8 @@ static void pgpring_find_candidates(char *ringfile, const char *hints[], int nhi
 
         /* Not bailing out here would lead us into an endless loop. */
 
-        if ((p = pgp_parse_keyblock(rfp)) == NULL)
+        p = pgp_parse_keyblock(rfp);
+        if (!p)
           err = 1;
 
         pgpring_dump_keyblock(p);
diff --git a/pop.c b/pop.c
index 4647665fb7cf8b2100e40eed410cfd73931bf8b0..0ab5349c46ef9c98f1ab853cf45fe7a56ece177f 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -725,7 +725,8 @@ static int pop_sync_mailbox(struct Context *ctx, int *index_hint)
         if (!ctx->quiet)
           mutt_progress_update(&progress, j, -1);
         snprintf(buf, sizeof(buf), "DELE %d\r\n", ctx->hdrs[i]->refno);
-        if ((ret = pop_query(pop_data, buf, sizeof(buf))) == 0)
+        ret = pop_query(pop_data, buf, sizeof(buf));
+        if (ret == 0)
         {
           mutt_bcache_del(pop_data->bcache, ctx->hdrs[i]->data);
 #ifdef USE_HCACHE
@@ -900,7 +901,8 @@ void pop_fetch_mail(void)
 
   for (int i = last + 1; i <= msgs; i++)
   {
-    if ((msg = mx_open_new_message(&ctx, NULL, MUTT_ADD_FROM)) == NULL)
+    msg = mx_open_new_message(&ctx, NULL, MUTT_ADD_FROM);
+    if (!msg)
       ret = -3;
     else
     {
index 93cb0ff900b848f92dc64a698b490f18abd07959..43be8d68c08d2b093e49bdb1598d549feb96a8c5 100644 (file)
@@ -268,7 +268,8 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr,
   if (!Postponed)
     return -1;
 
-  if ((PostContext = mx_open_mailbox(Postponed, MUTT_NOSORT, NULL)) == NULL)
+  PostContext = mx_open_mailbox(Postponed, MUTT_NOSORT, NULL);
+  if (!PostContext)
   {
     PostCount = 0;
     mutt_error(_("No postponed messages."));
@@ -659,7 +660,8 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr,
     }
 
     mutt_adv_mktemp(file, sizeof(file));
-    if ((s.fpout = safe_fopen(file, "w")) == NULL)
+    s.fpout = safe_fopen(file, "w");
+    if (!s.fpout)
       goto bail;
 
     if ((WithCrypto & APPLICATION_PGP) &&
index 8ddd7e9c4a03a94b18e5ea00205833dcac1819f2..04311c9ea51ae504acc69f9a35f1ad2b4c33e912 100644 (file)
@@ -470,7 +470,8 @@ static int query_save_attachment(FILE *fp, struct Body *body,
       struct stat st;
 
       /* check to make sure that this file is really the one the user wants */
-      if ((rc = mutt_save_confirm(buf, &st)) == 1)
+      rc = mutt_save_confirm(buf, &st);
+      if (rc == 1)
       {
         prompt = _("Save to file: ");
         continue;
@@ -641,7 +642,8 @@ static void pipe_attachment(FILE *fp, struct Body *b, struct State *state)
   }
   else
   {
-    if ((ifp = fopen(b->filename, "r")) == NULL)
+    ifp = fopen(b->filename, "r");
+    if (!ifp)
     {
       mutt_perror("fopen");
       return;
@@ -770,7 +772,8 @@ static void print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag,
           mutt_mktemp(newfile, sizeof(newfile));
           if (mutt_decode_save_attachment(fp, top, newfile, MUTT_PRINTING, 0) == 0)
           {
-            if ((ifp = fopen(newfile, "r")) != NULL)
+            ifp = fopen(newfile, "r");
+            if (ifp)
             {
               mutt_copy_stream(ifp, state->fpout);
               safe_fclose(&ifp);
@@ -1121,7 +1124,8 @@ void mutt_view_attachments(struct Header *hdr)
 
   mutt_message_hook(Context, hdr, MUTT_MESSAGEHOOK);
 
-  if ((msg = mx_open_message(Context, hdr->msgno)) == NULL)
+  msg = mx_open_message(Context, hdr->msgno);
+  if (!msg)
     return;
 
   menu = mutt_new_menu(MENU_ATTACH);
index a9c64490ef2a1265f3148aee3a2286e20fc07700..e12a284c7ce2caec60f14f1202b60856b19fbb7f 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -417,7 +417,8 @@ static void attach_forward_bodies(FILE *fp, struct Header *hdr, struct AttachCtx
   mutt_make_forward_subject(tmphdr->env, Context, parent_hdr);
 
   mutt_mktemp(tmpbody, sizeof(tmpbody));
-  if ((tmpfp = safe_fopen(tmpbody, "w")) == NULL)
+  tmpfp = safe_fopen(tmpbody, "w");
+  if (!tmpfp)
   {
     mutt_error(_("Can't open temporary file %s."), tmpbody);
     mutt_free_header(&tmphdr);
@@ -814,7 +815,8 @@ void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx,
   if (!check_all_msg(actx, cur, false))
   {
     nattach = count_tagged(actx);
-    if ((parent = find_parent(actx, cur, nattach)) != NULL)
+    parent = find_parent(actx, cur, nattach);
+    if (parent)
     {
       parent_hdr = parent->content->hdr;
       parent_fp = parent->fp;
@@ -849,7 +851,8 @@ void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx,
   }
 
   mutt_mktemp(tmpbody, sizeof(tmpbody));
-  if ((tmpfp = safe_fopen(tmpbody, "w")) == NULL)
+  tmpfp = safe_fopen(tmpbody, "w");
+  if (!tmpfp)
   {
     mutt_error(_("Can't create %s."), tmpbody);
     mutt_free_header(&tmphdr);
index 8f33d283a9ed09c282cf09d336d2f11099664f55..d7e25e79b421c7650510a6ce54fce524c247430a 100644 (file)
@@ -142,12 +142,14 @@ static struct Remailer **mix_type2_list(size_t *l)
   if (!l)
     return NULL;
 
-  if ((devnull = open("/dev/null", O_RDWR)) == -1)
+  devnull = open("/dev/null", O_RDWR);
+  if (devnull == -1)
     return NULL;
 
   snprintf(cmd, sizeof(cmd), "%s -T", Mixmaster);
 
-  if ((mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, devnull, -1, devnull)) == -1)
+  mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, devnull, -1, devnull);
+  if (mm_pid == -1)
   {
     close(devnull);
     return NULL;
index 0aba12ea23ee00c03e052542572d52424e446adb..a343ed05e2a75e2b832ed3ffd2e58897530952a0 100644 (file)
--- a/resize.c
+++ b/resize.c
@@ -50,7 +50,8 @@ void mutt_resize_screen(void)
 
   SLtt_Screen_Rows = -1;
   SLtt_Screen_Cols = -1;
-  if ((fd = open("/dev/tty", O_RDONLY)) != -1)
+  fd = open("/dev/tty", O_RDONLY);
+  if (fd != -1)
   {
     if (ioctl(fd, TIOCGWINSZ, &w) != -1)
     {
index 990bebe06bdd45151d2a1f8edba270e576dbaddf..49a6e3decef40bc7791c60e5f43ad51a8f4149f2 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -202,11 +202,13 @@ static int rfc1524_mailcap_parse(struct Body *a, char *filename, char *type,
    */
 
   /* find length of basetype */
-  if ((ch = strchr(type, '/')) == NULL)
+  ch = strchr(type, '/');
+  if (!ch)
     return false;
   btlen = ch - type;
 
-  if ((fp = fopen(filename, "r")) != NULL)
+  fp = fopen(filename, "r");
+  if (fp)
   {
     while (!found && (buf = mutt_read_line(buf, &buflen, fp, &line, MUTT_CONT)) != NULL)
     {
@@ -592,9 +594,11 @@ int mutt_rename_file(char *oldfile, char *newfile)
     return 1;
   if (access(newfile, F_OK) == 0)
     return 2;
-  if ((ofp = fopen(oldfile, "r")) == NULL)
+  ofp = fopen(oldfile, "r");
+  if (!ofp)
     return 3;
-  if ((nfp = safe_fopen(newfile, "w")) == NULL)
+  nfp = safe_fopen(newfile, "w");
+  if (!nfp)
   {
     safe_fclose(&ofp);
     return 3;
index 7e3ba8feea42af06bb1aac3003c034e82def6694..64e8dfadc83c182b0fdfe3a76270c4e4dc05ed15 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -858,7 +858,8 @@ void rfc2047_decode(char **pd)
           s += m;
         }
 
-        if ((m = n - lwsrlen(s, n)) != 0)
+        m = n - lwsrlen(s, n);
+        if (m != 0)
         {
           if (m > dlen)
             m = dlen;
index 099dab78ff1ba932f147159365ce7f4c91c5f7b1..5206044cdb82cf65b6892db894ce46fb7c5545a6 100644 (file)
--- a/rfc3676.c
+++ b/rfc3676.c
@@ -365,11 +365,13 @@ void rfc3676_space_stuff(struct Header *hdr)
 
   mutt_debug(2, "f=f: postprocess %s\n", hdr->content->filename);
 
-  if ((in = safe_fopen(hdr->content->filename, "r")) == NULL)
+  in = safe_fopen(hdr->content->filename, "r");
+  if (!in)
     return;
 
   mutt_mktemp(tmpfile, sizeof(tmpfile));
-  if ((out = safe_fopen(tmpfile, "w+")) == NULL)
+  out = safe_fopen(tmpfile, "w+");
+  if (!out)
   {
     safe_fclose(&in);
     return;
index 71388e8253d19be48dcf5de04cf06dc00753e4f0..204c1e62f6a88f7b2a9a005cdd15b6b16945b78d 100644 (file)
--- a/rfc822.c
+++ b/rfc822.c
@@ -353,7 +353,8 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s)
     {
       if (commentlen && commentlen < sizeof(comment) - 1)
         comment[commentlen++] = ' ';
-      if ((ps = next_token(s, comment, &commentlen, sizeof(comment) - 1)) == NULL)
+      ps = next_token(s, comment, &commentlen, sizeof(comment) - 1);
+      if (!ps)
       {
         rfc822_free_address(&top);
         return NULL;
@@ -364,7 +365,8 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s)
     {
       if (phraselen && phraselen < sizeof(phrase) - 1)
         phrase[phraselen++] = ' ';
-      if ((ps = parse_quote(s + 1, phrase, &phraselen, sizeof(phrase) - 1)) == NULL)
+      ps = parse_quote(s + 1, phrase, &phraselen, sizeof(phrase) - 1);
+      if (!ps)
       {
         rfc822_free_address(&top);
         return NULL;
@@ -419,7 +421,8 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s)
       cur = rfc822_new_address();
       if (phraselen)
         cur->personal = safe_strdup(phrase);
-      if ((ps = parse_route_addr(s + 1, comment, &commentlen, sizeof(comment) - 1, cur)) == NULL)
+      ps = parse_route_addr(s + 1, comment, &commentlen, sizeof(comment) - 1, cur);
+      if (!ps)
       {
         rfc822_free_address(&top);
         rfc822_free_address(&cur);
@@ -440,7 +443,8 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s)
     {
       if (phraselen && phraselen < sizeof(phrase) - 1 && ws_pending)
         phrase[phraselen++] = ' ';
-      if ((ps = next_token(s, phrase, &phraselen, sizeof(phrase) - 1)) == NULL)
+      ps = next_token(s, phrase, &phraselen, sizeof(phrase) - 1);
+      if (!ps)
       {
         rfc822_free_address(&top);
         return NULL;
diff --git a/score.c b/score.c
index 56e698ed120b9f97daba8c655678d0d8a4920283..490cdbd3ac7c5c1ca9f1d4d7667d73d27508f152 100644 (file)
--- a/score.c
+++ b/score.c
@@ -103,7 +103,8 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data,
       break;
   if (!ptr)
   {
-    if ((pat = mutt_pattern_comp(pattern, 0, err)) == NULL)
+    pat = mutt_pattern_comp(pattern, 0, err);
+    if (!pat)
     {
       FREE(&pattern);
       return -1;
diff --git a/send.c b/send.c
index f71c2b94695a9d45b946b3b945d123bbe973b72d..1ace79803de6621883eb47ddcf9d66d1bbba0358 100644 (file)
--- a/send.c
+++ b/send.c
@@ -236,7 +236,8 @@ static int edit_address(struct Address **a, /* const */ char *field)
       return -1;
     rfc822_free_address(a);
     *a = mutt_expand_aliases(mutt_parse_adrlist(NULL, buf));
-    if ((idna_ok = mutt_addrlist_to_intl(*a, &err)) != 0)
+    idna_ok = mutt_addrlist_to_intl(*a, &err);
+    if (idna_ok != 0)
     {
       mutt_error(_("Error: '%s' is a bad IDN."), err);
       mutt_refresh();
@@ -615,7 +616,8 @@ int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags)
              in->mail_followup_to->mailbox,
              in->mail_followup_to->next ? ",..." : "");
 
-    if ((hmfupto = query_quadoption(OPT_HONOR_FOLLOWUP_TO, prompt)) == MUTT_ABORT)
+    hmfupto = query_quadoption(OPT_HONOR_FOLLOWUP_TO, prompt);
+    if (hmfupto == MUTT_ABORT)
       return -1;
   }
 
@@ -852,7 +854,8 @@ static int generate_body(FILE *tempfp, struct Header *msg, int flags,
 
   if (flags & SENDREPLY)
   {
-    if ((i = query_quadoption(OPT_INCLUDE, _("Include message in reply?"))) == MUTT_ABORT)
+    i = query_quadoption(OPT_INCLUDE, _("Include message in reply?"));
+    if (i == MUTT_ABORT)
       return -1;
 
     if (i == MUTT_YES)
@@ -880,7 +883,8 @@ static int generate_body(FILE *tempfp, struct Header *msg, int flags,
   }
   else if (flags & SENDFORWARD)
   {
-    if ((i = query_quadoption(OPT_MIME_FORWARD, _("Forward as attachment?"))) == MUTT_YES)
+    i = query_quadoption(OPT_MIME_FORWARD, _("Forward as attachment?"));
+    if (i == MUTT_YES)
     {
       struct Body *last = msg->content;
 
@@ -1088,7 +1092,8 @@ static int send_message(struct Header *msg)
 
   /* Write out the message in MIME form. */
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((tempfp = safe_fopen(tempfile, "w")) == NULL)
+  tempfp = safe_fopen(tempfile, "w");
+  if (!tempfp)
     return -1;
 
 #ifdef USE_SMTP
@@ -1178,7 +1183,8 @@ static void fix_end_of_file(const char *data)
 {
   FILE *fp = NULL;
 
-  if ((fp = safe_fopen(data, "a+")) == NULL)
+  fp = safe_fopen(data, "a+");
+  if (!fp)
     return;
   if (fseek(fp, -1, SEEK_END) >= 0)
   {
@@ -1338,7 +1344,8 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile,
     /* If the user is composing a new message, check to see if there
      * are any postponed messages first.
      */
-    if ((i = query_quadoption(OPT_RECALL, _("Recall postponed message?"))) == MUTT_ABORT)
+    i = query_quadoption(OPT_RECALL, _("Recall postponed message?"));
+    if (i == MUTT_ABORT)
       return rv;
 
     if (i == MUTT_YES)
@@ -1386,7 +1393,8 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile,
 
     if (flags & (SENDPOSTPONED | SENDRESEND))
     {
-      if ((tempfp = safe_fopen(msg->content->filename, "a+")) == NULL)
+      tempfp = safe_fopen(msg->content->filename, "a+");
+      if (!tempfp)
       {
         mutt_perror(msg->content->filename);
         goto cleanup;
index ef1368a0584111b39bf482c268c45175791c9fec..2ff4b2443526020374318ed04d1468852ad6f2dd 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -465,7 +465,8 @@ int mutt_write_mime_body(struct Body *a, FILE *f)
     return 0;
   }
 
-  if ((fpin = fopen(a->filename, "r")) == NULL)
+  fpin = fopen(a->filename, "r");
+  if (!fpin)
   {
     mutt_debug(1, "write_mime_body: %s no longer exists!\n", a->filename);
     mutt_error(_("%s no longer exists!"), a->filename);
@@ -835,7 +836,8 @@ static size_t convert_file_from_to(FILE *file, const char *fromcodes, const char
   ncodes = 0;
   for (c = tocodes; c; c = c1 ? c1 + 1 : 0)
   {
-    if ((c1 = strchr(c, ':')) == c)
+    c1 = strchr(c, ':');
+    if (c1 == c)
       continue;
     ncodes++;
   }
@@ -844,7 +846,8 @@ static size_t convert_file_from_to(FILE *file, const char *fromcodes, const char
   tcode = safe_malloc(ncodes * sizeof(char *));
   for (c = tocodes, i = 0; c; c = c1 ? c1 + 1 : 0, i++)
   {
-    if ((c1 = strchr(c, ':')) == c)
+    c1 = strchr(c, ':');
+    if (c1 == c)
       continue;
     tcode[i] = mutt_substrdup(c, c1);
   }
@@ -855,7 +858,8 @@ static size_t convert_file_from_to(FILE *file, const char *fromcodes, const char
     /* Try each fromcode in turn */
     for (c = fromcodes; c; c = c1 ? c1 + 1 : 0)
     {
-      if ((c1 = strchr(c, ':')) == c)
+      c1 = strchr(c, ':');
+      if (c1 == c)
         continue;
       fcode = mutt_substrdup(c, c1);
 
@@ -923,7 +927,8 @@ struct Content *mutt_get_content_info(const char *fname, struct Body *b)
     return NULL;
   }
 
-  if ((fp = fopen(fname, "r")) == NULL)
+  fp = fopen(fname, "r");
+  if (!fp)
   {
     mutt_debug(1, "mutt_get_content_info: %s: %s (errno %d).\n", fname,
                strerror(errno), errno);
@@ -1030,7 +1035,8 @@ int mutt_lookup_mime_type(struct Body *att, const char *path)
         goto bye; /* shouldn't happen */
     }
 
-    if ((f = fopen(buf, "r")) != NULL)
+    f = fopen(buf, "r");
+    if (f)
     {
       found_mimetypes = true;
 
@@ -1045,7 +1051,8 @@ int mutt_lookup_mime_type(struct Body *att, const char *path)
         SKIPWS(ct);
 
         /* position on the next field in this line */
-        if ((p = strpbrk(ct, " \t")) == NULL)
+        p = strpbrk(ct, " \t");
+        if (!p)
           continue;
         *p++ = 0;
         SKIPWS(p);
@@ -1061,7 +1068,8 @@ int mutt_lookup_mime_type(struct Body *att, const char *path)
           {
             /* get the content-type */
 
-            if ((p = strchr(ct, '/')) == NULL)
+            p = strchr(ct, '/');
+            if (!p)
             {
               /* malformed line, just skip it. */
               break;
@@ -1073,7 +1081,8 @@ int mutt_lookup_mime_type(struct Body *att, const char *path)
 
             mutt_substrcpy(subtype, p, q, sizeof(subtype));
 
-            if ((type = mutt_check_mime_type(ct)) == TYPEOTHER)
+            type = mutt_check_mime_type(ct);
+            if (type == TYPEOTHER)
               strfcpy(xtype, ct, sizeof(xtype));
 
             cur_sze = sze;
@@ -1129,7 +1138,8 @@ static void transform_to_7bit(struct Body *a, FILE *fpin)
       a->force_charset = true;
 
       mutt_mktemp(buff, sizeof(buff));
-      if ((s.fpout = safe_fopen(buff, "w")) == NULL)
+      s.fpout = safe_fopen(buff, "w");
+      if (!s.fpout)
       {
         mutt_perror("fopen");
         return;
@@ -1320,7 +1330,8 @@ void mutt_update_encoding(struct Body *a)
   if (!a->force_charset && !a->noconv)
     mutt_delete_parameter("charset", &a->parameter);
 
-  if ((info = mutt_get_content_info(a->filename, a)) == NULL)
+  info = mutt_get_content_info(a->filename, a);
+  if (!info)
     return;
 
   set_encoding(a, info);
@@ -1349,7 +1360,8 @@ struct Body *mutt_make_message_attach(struct Context *ctx, struct Header *hdr, i
   }
 
   mutt_mktemp(buffer, sizeof(buffer));
-  if ((fp = safe_fopen(buffer, "w+")) == NULL)
+  fp = safe_fopen(buffer, "w+");
+  if (!fp)
     return NULL;
 
   body = mutt_new_body();
@@ -1436,7 +1448,8 @@ static void run_mime_type_query(struct Body *att)
     return;
   }
 
-  if ((buf = mutt_read_line(buf, &buflen, fp, &dummy, 0)) != NULL)
+  buf = mutt_read_line(buf, &buflen, fp, &dummy, 0);
+  if (buf)
   {
     if (strchr(buf, '/'))
       mutt_parse_content_type(buf, att);
@@ -1469,7 +1482,8 @@ struct Body *mutt_make_file_attach(const char *path)
       !option(OPT_MIME_TYPE_QUERY_FIRST))
     run_mime_type_query(att);
 
-  if ((info = mutt_get_content_info(path, att)) == NULL)
+  info = mutt_get_content_info(path, att);
+  if (!info)
   {
     mutt_free_body(&att);
     return NULL;
@@ -2316,7 +2330,8 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf
     *tempfile = safe_strdup(tmp);
   }
 
-  if ((pid = fork()) == 0)
+  pid = fork();
+  if (pid == 0)
   {
     struct sigaction act, oldalrm;
 
@@ -2345,7 +2360,8 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf
 #endif
 
     /* now the second fork() */
-    if ((pid = fork()) == 0)
+    pid = fork();
+    if (pid == 0)
     {
       /* "msg" will be opened as stdin */
       if (open(msg, O_RDONLY, 0) < 0)
@@ -2749,7 +2765,8 @@ static int _mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to,
     fp = msg->fp;
 
   mutt_mktemp(tempfile, sizeof(tempfile));
-  if ((f = safe_fopen(tempfile, "w")) != NULL)
+  f = safe_fopen(tempfile, "w");
+  if (f)
   {
     int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
     char *msgid_str = NULL;
@@ -2971,7 +2988,8 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid,
   if (f.magic == MUTT_MMDF || f.magic == MUTT_MBOX)
   {
     mutt_mktemp(tempfile, sizeof(tempfile));
-    if ((tempfp = safe_fopen(tempfile, "w+")) == NULL)
+    tempfp = safe_fopen(tempfile, "w+");
+    if (!tempfp)
     {
       mutt_perror(tempfile);
       mx_close_mailbox(&f, NULL);
@@ -2986,7 +3004,8 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid,
   onm_flags = MUTT_ADD_FROM;
   if (post)
     onm_flags |= MUTT_SET_DRAFT;
-  if ((msg = mx_open_new_message(&f, hdr, onm_flags)) == NULL)
+  msg = mx_open_new_message(&f, hdr, onm_flags);
+  if (!msg)
   {
     safe_fclose(&tempfp);
     mx_close_mailbox(&f, NULL);
index 84ed59d0074d94640f2395cf5198e9495518621b..8e3cd0ebe2688e2b306af42ba57d2e22c43942d9 100644 (file)
--- a/system.c
+++ b/system.c
@@ -57,7 +57,8 @@ int mutt_system(const char *cmd)
   sigaction(SIGTSTP, &act, &oldtstp);
   sigaction(SIGCONT, &act, &oldcont);
 
-  if ((thepid = fork()) == 0)
+  thepid = fork();
+  if (thepid == 0)
   {
     act.sa_flags = 0;
 
index ea00edcb62f5aa408504c0930c86a4d0afc91583..66a8b36930c4851dcf806cb7794334d1a4332d1f 100644 (file)
--- a/thread.c
+++ b/thread.c
@@ -541,7 +541,8 @@ static void pseudo_threads(struct Context *ctx)
   {
     cur = tree;
     tree = tree->next;
-    if ((parent = find_subject(ctx, cur)) != NULL)
+    parent = find_subject(ctx, cur);
+    if (parent)
     {
       cur->fake_thread = true;
       unlink_message(&top, cur);
@@ -920,7 +921,8 @@ void mutt_sort_threads(struct Context *ctx, int init)
       if (using_refs == 0)
       {
         /* look at the beginning of in-reply-to: */
-        if ((ref = STAILQ_FIRST(&cur->env->in_reply_to)) != NULL)
+        ref = STAILQ_FIRST(&cur->env->in_reply_to);
+        if (ref)
           using_refs = 1;
         else
         {
@@ -954,7 +956,8 @@ void mutt_sort_threads(struct Context *ctx, int init)
       if (!ref)
         break;
 
-      if ((new = hash_find(ctx->thread_hash, ref->data)) == NULL)
+      new = hash_find(ctx->thread_hash, ref->data);
+      if (!new)
       {
         new = safe_calloc(1, sizeof(struct MuttThread));
         hash_insert(ctx->thread_hash, ref->data, new);
@@ -1014,7 +1017,8 @@ static struct Header *find_virtual(struct MuttThread *cur, int reverse)
     return cur->message;
 
   top = cur;
-  if ((cur = cur->child) == NULL)
+  cur = cur->child;
+  if (!cur)
     return NULL;
 
   while (reverse && cur->next)
@@ -1128,7 +1132,8 @@ int mutt_parent_message(struct Context *ctx, struct Header *hdr, int find_root)
 
   for (thread = hdr->thread->parent; thread; thread = thread->parent)
   {
-    if ((hdr = thread->message) != NULL)
+    hdr = thread->message;
+    if (hdr)
     {
       parent = hdr;
       if (!find_root)
diff --git a/url.c b/url.c
index e5c0d40211fb8aaf6289534d8ef80c9faf4920cb..95c87531adbbd75826342b2913f603c3d002d878 100644 (file)
--- a/url.c
+++ b/url.c
@@ -90,7 +90,8 @@ enum UrlScheme url_check_scheme(const char *s)
   for (t = sbuf; *t; t++)
     *t = tolower(*t);
 
-  if ((i = mutt_getvaluebyname(sbuf, UrlMap)) == -1)
+  i = mutt_getvaluebyname(sbuf, UrlMap);
+  if (i == -1)
     return U_UNKNOWN;
   else
     return (enum UrlScheme) i;
@@ -174,7 +175,8 @@ int url_parse(struct Url *u, char *src)
 {
   char *tmp = NULL;
 
-  if ((u->scheme = url_check_scheme(src)) == U_UNKNOWN)
+  u->scheme = url_check_scheme(src);
+  if (u->scheme == U_UNKNOWN)
     return -1;
 
   tmp = strchr(src, ':') + 1;
@@ -273,7 +275,8 @@ int url_parse_mailto(struct Envelope *e, char **body, const char *src)
     return -1;
 
   /* copy string for safe use of strtok() */
-  if ((tmp = safe_strdup(t + 1)) == NULL)
+  tmp = safe_strdup(t + 1);
+  if (!tmp)
     return -1;
 
   if ((headers = strchr(tmp, '?')))