From: Richard Russon Date: Wed, 17 Feb 2016 19:12:56 +0000 (+0000) Subject: tidy code X-Git-Tag: neomutt-20160404~11^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fc6525c0e36027a050de4585839ad1e2b8c040a;p=neomutt tidy code --- diff --git a/handler.c b/handler.c index 307f747d1..606829143 100644 --- a/handler.c +++ b/handler.c @@ -1626,8 +1626,8 @@ static int run_decode_and_handler (BODY *b, STATE *s, handler_t handler, int pla /* decode to a tempfile, saving the original destination */ fp = s->fpout; #ifdef HAVE_FMEMOPEN - if ((s->fpout = open_memstream(&temp, &tempsize)) == NULL) - { + s->fpout = open_memstream (&temp, &tempsize); + if (!s->fpout) { mutt_error _("Unable to open memory stream!"); dprint (1, (debugfile, "Can't open memory stream.\n")); return -1; @@ -1670,13 +1670,14 @@ static int run_decode_and_handler (BODY *b, STATE *s, handler_t handler, int pla s->fpout = fp; fp = s->fpin; #ifdef HAVE_FMEMOPEN - if(tempsize) - s->fpin = fmemopen(temp, tempsize, "r"); - else /* fmemopen cannot handle zero-length buffers */ + if (tempsize) { + s->fpin = fmemopen (temp, tempsize, "r"); + } else { /* fmemopen cannot handle zero-length buffers */ s->fpin = safe_fopen ("/dev/null", "r"); - if(s->fpin == NULL) { - mutt_perror("failed to re-open memstream!"); - return (-1); + } + if (!s->fpin) { + mutt_perror ("failed to re-open memstream!"); + return -1; } #else s->fpin = fopen (tempfile, "r"); @@ -1707,8 +1708,8 @@ static int run_decode_and_handler (BODY *b, STATE *s, handler_t handler, int pla /* restore the original source stream */ safe_fclose (&s->fpin); #ifdef HAVE_FMEMOPEN - if(tempsize) - FREE(&temp); + if (tempsize) + FREE(&temp); #endif s->fpin = fp; } diff --git a/pattern.c b/pattern.c index 13f0e203f..c170edebe 100644 --- a/pattern.c +++ b/pattern.c @@ -169,10 +169,10 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) s.fpin = msg->fp; s.flags = M_CHARCONV; #ifdef HAVE_FMEMOPEN - if((s.fpout = open_memstream(&temp, &tempsize)) == NULL) - { + s.fpout = open_memstream (&temp, &tempsize); + if (!s.fpout) { mutt_perror ("Error opening memstream"); - return (0); + return 0; } #else mutt_mktemp (tempfile, sizeof (tempfile)); @@ -211,19 +211,21 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) } #ifdef HAVE_FMEMOPEN - fclose(s.fpout); + fclose (s.fpout); lng = tempsize; - if(tempsize) { - if ((fp = fmemopen(temp, tempsize, "r")) == NULL) { - mutt_perror ("Error re-opening memstream"); - return (0); - } + if (tempsize) { + fp = fmemopen (temp, tempsize, "r"); + if (!fp) { + mutt_perror ("Error re-opening memstream"); + return 0; + } } else { /* fmemopen cannot handle empty buffers */ - if ((fp = safe_fopen ("/dev/null", "r")) == NULL) { - mutt_perror ("Error opening /dev/null"); - return (0); - } + fp = safe_fopen ("/dev/null", "r"); + if (!fp) { + mutt_perror ("Error opening /dev/null"); + return 0; + } } #else fp = s.fpout; @@ -279,8 +281,8 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) { safe_fclose (&fp); #ifdef HAVE_FMEMOPEN - if(tempsize) - FREE (&temp); + if (tempsize) + FREE(&temp); #else unlink (tempfile); #endif