]> granicus.if.org Git - neomutt/commitdiff
smime_handle_entity() cleanup
authorKevin McCarthy <kevin@8t8.us>
Mon, 2 Jul 2018 03:43:24 +0000 (20:43 -0700)
committerRichard Russon <rich@flatcap.org>
Sat, 1 Sep 2018 17:06:08 +0000 (18:06 +0100)
Remove redundant NULL assignments after safe_fclose() calls.

Remove some trailing spaces.

smimeout can't be NULL, so remove the check around the output
translation block.

ncrypt/smime.c

index 815742cc728238fc3fdbad5c683ebb42c18c407f..91c7b766cd59339d3f173b3640631df872843ff8 100644 (file)
@@ -2113,74 +2113,70 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o
       state_attach_puts(_("[-- The following data is S/MIME signed --]\n"), s);
   }
 
-  if (smimeout)
-  {
-    fflush(smimeout);
-    rewind(smimeout);
+  fflush(smimeout);
+  rewind(smimeout);
 
-    if (type & ENCRYPT)
+  if (type & ENCRYPT)
+  {
+    /* void the passphrase, even if that wasn't the problem */
+    if (fgetc(smimeout) == EOF)
     {
-      /* void the passphrase, even if that wasn't the problem */
-      if (fgetc(smimeout) == EOF)
-      {
-        mutt_error(_("Decryption failed"));
-        smime_class_void_passphrase();
-      }
-      rewind(smimeout);
+      mutt_error(_("Decryption failed"));
+      smime_class_void_passphrase();
     }
+    rewind(smimeout);
+  }
 
-    if (out_file)
-      fpout = out_file;
-    else
+  if (out_file)
+    fpout = out_file;
+  else
+  {
+    fpout = mutt_file_mkstemp();
+    if (!fpout)
     {
-      fpout = mutt_file_mkstemp();
-      if (!fpout)
-      {
-        mutt_perror(_("Can't create temporary file"));
-        mutt_file_fclose(&smimeout);
-        mutt_file_fclose(&smimeerr);
-        return NULL;
-      }
+      mutt_perror(_("Can't create temporary file"));
+      mutt_file_fclose(&smimeout);
+      mutt_file_fclose(&smimeerr);
+      return NULL;
     }
-    char buf[HUGE_STRING];
-    while (fgets(buf, sizeof(buf) - 1, smimeout))
+  }
+  char buf[HUGE_STRING];
+  while (fgets(buf, sizeof(buf) - 1, smimeout))
+  {
+    const size_t len = mutt_str_strlen(buf);
+    if (len > 1 && buf[len - 2] == '\r')
     {
-      const size_t len = mutt_str_strlen(buf);
-      if (len > 1 && buf[len - 2] == '\r')
-      {
-        buf[len - 2] = '\n';
-        buf[len - 1] = '\0';
-      }
-      fputs(buf, fpout);
+      buf[len - 2] = '\n';
+      buf[len - 1] = '\0';
     }
-    fflush(fpout);
-    rewind(fpout);
-
-    p = mutt_read_mime_header(fpout, 0);
-    if (p)
-    {
-      fstat(fileno(fpout), &info);
-      p->length = info.st_size - p->offset;
+    fputs(buf, fpout);
+  }
+  fflush(fpout);
+  rewind(fpout);
 
-      mutt_parse_part(fpout, p);
-      if (s->fpout)
-      {
-        rewind(fpout);
-        tmpfp_buffer = s->fpin;
-        s->fpin = fpout;
-        mutt_body_handler(p, s);
-        s->fpin = tmpfp_buffer;
-      }
-    }
-    mutt_file_fclose(&smimeout);
-    smimeout = NULL;
+  p = mutt_read_mime_header(fpout, 0);
+  if (p)
+  {
+    fstat(fileno(fpout), &info);
+    p->length = info.st_size - p->offset;
 
-    if (!out_file)
+    mutt_parse_part(fpout, p);
+    if (s->fpout)
     {
-      mutt_file_fclose(&fpout);
+      rewind(fpout);
+      tmpfp_buffer = s->fpin;
+      s->fpin = fpout;
+      mutt_body_handler(p, s);
+      s->fpin = tmpfp_buffer;
     }
-    fpout = NULL;
   }
+  mutt_file_fclose(&smimeout);
+
+  if (!out_file)
+  {
+    mutt_file_fclose(&fpout);
+  }
+  fpout = NULL;
 
   if (s->flags & MUTT_DISPLAY)
   {