]> granicus.if.org Git - neomutt/commitdiff
light tidying
authorRichard Russon <rich@flatcap.org>
Sat, 22 Dec 2018 20:47:49 +0000 (20:47 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 22 Dec 2018 20:47:49 +0000 (20:47 +0000)
17 files changed:
account.c
bcache.c
conn/sasl.c
conn/socket.c
edit.c
editmsg.c
email/body.c
main.c
mutt/file.c
mutt_attach.c
ncrypt/pgplib.c
nntp/newsrc.c
nntp/nntp.c
pattern.c
rfc1524.c
sendlib.c
smtp.c

index fabae266f7508485187f1c6fd914fe33a35caff7..7b1fd4894a9f390d154a40997b141a03272f7b1d 100644 (file)
--- a/account.c
+++ b/account.c
@@ -64,7 +64,7 @@ void account_remove_mailbox(struct Account *a, struct Mailbox *m)
   if (STAILQ_EMPTY(&a->mailboxes))
   {
     TAILQ_REMOVE(&AllAccounts, a, entries);
-    if (a->adata)
+    if (a->free_adata)
       a->free_adata(&a->adata);
     FREE(&a);
   }
index a483d2a0eeb5c2eeb01c2f5bdb67576cced96801..6d7a5f04384affb2df5b85477ee0d35693def960 100644 (file)
--- a/bcache.c
+++ b/bcache.c
@@ -133,22 +133,18 @@ static int mutt_bcache_move(struct BodyCache *bcache, const char *id, const char
  */
 struct BodyCache *mutt_bcache_open(struct ConnAccount *account, const char *mailbox)
 {
-  struct BodyCache *bcache = NULL;
-
   if (!account)
-    goto bail;
+    return NULL;
 
-  bcache = mutt_mem_calloc(1, sizeof(struct BodyCache));
+  struct BodyCache *bcache = mutt_mem_calloc(1, sizeof(struct BodyCache));
   if (bcache_path(account, mailbox, bcache->path, sizeof(bcache->path)) < 0)
-    goto bail;
-  bcache->pathlen = mutt_str_strlen(bcache->path);
+  {
+    FREE(&bcache);
+    return NULL;
+  }
 
+  bcache->pathlen = mutt_str_strlen(bcache->path);
   return bcache;
-
-bail:
-  if (bcache)
-    FREE(&bcache);
-  return NULL;
 }
 
 /**
index edd65edfcbb2e1e6509af799835b6c8e58e3e1ab..684c13311d8d708c639c7679fd18001c6b4ac9a3 100644 (file)
@@ -144,7 +144,7 @@ static int iptostring(const struct sockaddr *addr, socklen_t addrlen, char *out,
                         NI_WITHSCOPEID |
 #endif
                         NI_NUMERICSERV);
-  if (ret)
+  if (ret != 0)
     return getnameinfo_err(ret);
 
   if (outlen < strlen(hbuf) + strlen(pbuf) + 2)
index 6cb2983a47933f9d480e85cfaeefe3efb19e57d9..c3d643c2ddde4701b59d123ecabe6412995325c9 100644 (file)
@@ -106,6 +106,9 @@ int mutt_socket_open(struct Connection *conn)
  */
 int mutt_socket_close(struct Connection *conn)
 {
+  if (!conn)
+    return 0;
+
   int rc = -1;
 
   if (conn->fd < 0)
diff --git a/edit.c b/edit.c
index b2fc3f070a5c7f2b984f7a7bb99a54196a420001..bc2dd65496356827bbe8ad1d74c054ee651610b4 100644 (file)
--- a/edit.c
+++ b/edit.c
@@ -192,8 +192,7 @@ static void be_free_memory(char **buf, int buflen)
 {
   while (buflen-- > 0)
     FREE(&buf[buflen]);
-  if (buf)
-    FREE(&buf);
+  FREE(&buf);
 }
 
 /**
index c49d12af356e5fe0f1391179a7a3446db23e147f..e6b1c7956103235981c24b7162c0dbc8d6effcce 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -238,8 +238,7 @@ static int edit_or_view_one_message(bool edit, struct Mailbox *m, struct Email *
   mx_mbox_close(&tmpctx, NULL);
 
 bail:
-  if (fp)
-    mutt_file_fclose(&fp);
+  mutt_file_fclose(&fp);
 
   if (rc >= 0)
     unlink(tmp);
index 7628f73aa453ca9d8668774c6c8eb7851660d0e5..f4e05064d4f0b37cef92e48ebc626991a9be368c 100644 (file)
@@ -55,6 +55,9 @@ struct Body *mutt_body_new(void)
  */
 void mutt_body_free(struct Body **p)
 {
+  if (!p)
+    return;
+
   struct Body *a = *p, *b = NULL;
 
   while (a)
@@ -87,9 +90,7 @@ void mutt_body_free(struct Body **p)
       mutt_email_free(&b->email);
     }
 
-    if (b->parts)
-      mutt_body_free(&b->parts);
-
+    mutt_body_free(&b->parts);
     FREE(&b);
   }
 
diff --git a/main.c b/main.c
index de6ad1379ebb49fd5725a8eb1e84cf13e473ee49..fe1ec32946394520ca1182adae7ef3478e6123a0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1022,8 +1022,7 @@ int main(int argc, char *argv[], char *envp[])
       else
         bodyfile = tempfile;
 
-      if (fin)
-        mutt_file_fclose(&fin);
+      mutt_file_fclose(&fin);
     }
 
     FREE(&bodytext);
@@ -1214,8 +1213,7 @@ int main(int argc, char *argv[], char *envp[])
       mutt_sb_set_open_mailbox();
 #endif
       mutt_index_menu();
-      if (Context)
-        mutt_context_free(&Context);
+      mutt_context_free(&Context);
     }
 #ifdef USE_IMAP
     imap_logout_all();
index ed82932d8bd062f86d4f6b414c9ddd5da808f858..0199f5d5ede9d9a846f4389a5dc45519cfde45b6 100644 (file)
@@ -148,11 +148,10 @@ static int put_file_in_place(const char *path, const char *safe_file, const char
  */
 int mutt_file_fclose(FILE **f)
 {
-  int r = 0;
-
-  if (*f)
-    r = fclose(*f);
+  if (!f || !*f)
+    return 0;
 
+  int r = fclose(*f);
   *f = NULL;
   return r;
 }
index c2f3e5bb788143cb07c4776b596ce1b5a48c85c9..f6387aa5c789ce1f8b55ca448fe4fe3f59388f23 100644 (file)
@@ -96,10 +96,8 @@ int mutt_get_tmp_attachment(struct Body *a)
   else
     mutt_perror(fpin ? tempfile : a->filename);
 
-  if (fpin)
-    mutt_file_fclose(&fpin);
-  if (fpout)
-    mutt_file_fclose(&fpout);
+  mutt_file_fclose(&fpin);
+  mutt_file_fclose(&fpout);
 
   return a->unlink ? 0 : -1;
 }
index a1970f5c323c1bf654375ac10b5a5d2deb2f25d4..1dea5465fd41bf6ede48b7ca3a9bc56ac658fe78 100644 (file)
@@ -161,12 +161,10 @@ struct PgpUid *pgp_copy_uids(struct PgpUid *up, struct PgpKeyInfo *parent)
  */
 static void free_key(struct PgpKeyInfo **kpp)
 {
-  struct PgpKeyInfo *kp = NULL;
-
   if (!kpp || !*kpp)
     return;
 
-  kp = *kpp;
+  struct PgpKeyInfo *kp = *kpp;
 
   pgp_free_uid(&kp->address);
   FREE(&kp->keyid);
@@ -237,9 +235,8 @@ void pgp_free_key(struct PgpKeyInfo **kpp)
       r = q->next;
       free_key(&q);
     }
-    if (p->parent)
-      free_key(&p->parent);
 
+    free_key(&p->parent);
     free_key(&p);
   }
 
index 20a627254f10754f5e643dc7b8aab74729ec0201..314a3fa9914f376842073c594ebee4dfea4816d0 100644 (file)
@@ -434,8 +434,8 @@ static int update_file(char *filename, char *buf)
     rc = 0;
     break;
   }
-  if (fp)
-    mutt_file_fclose(&fp);
+  mutt_file_fclose(&fp);
+
   if (*tmpfile)
     unlink(tmpfile);
   return rc;
index daaaca4d6d22f3eb86e767f4c6ccdbc64b37d1d2..dfc2696d1db621343650a21b8fef1bc31016da32 100644 (file)
@@ -412,8 +412,7 @@ static int nntp_attempt_features(struct NntpAccountData *adata)
       int cont = 0;
       size_t buflen = 2 * LONG_STRING, off = 0, b = 0;
 
-      if (adata->overview_fmt)
-        FREE(&adata->overview_fmt);
+      FREE(&adata->overview_fmt);
       adata->overview_fmt = mutt_mem_malloc(buflen);
 
       while (true)
index d25380a95922cfb85a0c287a7076f8b7d8a5d786..aa39699c41bb0cf92f2159129186c9731a71ce81 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1336,6 +1336,9 @@ static /* const */ char *find_matching_paren(/* const */ char *s)
  */
 void mutt_pattern_free(struct Pattern **pat)
 {
+  if (!pat || !*pat)
+    return;
+
   struct Pattern *tmp = NULL;
 
   while (*pat)
@@ -1355,8 +1358,7 @@ void mutt_pattern_free(struct Pattern **pat)
       FREE(&tmp->p.regex);
     }
 
-    if (tmp->child)
-      mutt_pattern_free(&tmp->child);
+    mutt_pattern_free(&tmp->child);
     FREE(&tmp);
   }
 }
@@ -2430,8 +2432,7 @@ int mutt_pattern_func(int op, char *prompt)
   {
     /* drop previous limit pattern */
     FREE(&Context->pattern);
-    if (Context->limit_pattern)
-      mutt_pattern_free(&Context->limit_pattern);
+    mutt_pattern_free(&Context->limit_pattern);
 
     if (Context->mailbox->msg_count && !Context->mailbox->vcount)
       mutt_error(_("No messages matched criteria"));
index 76c58b733372b578d966ad46973bda5174cdbfbd..eeeaf43a2a751e38c16332a6d3d44ff6e7a8991b 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -410,6 +410,9 @@ struct Rfc1524MailcapEntry *rfc1524_new_entry(void)
  */
 void rfc1524_free_entry(struct Rfc1524MailcapEntry **entry)
 {
+  if (!entry || !*entry)
+    return;
+
   struct Rfc1524MailcapEntry *p = *entry;
 
   FREE(&p->command);
index f08eba53992fbdbe52e5bd0e6a23054a65c3d7f1..93a14f2e160937310cf4a9fd32200bb1234de0b0 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2578,8 +2578,7 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf
     else if (pid == -1)
     {
       unlink(msg);
-      if (tempfile)
-        FREE(tempfile);
+      FREE(tempfile);
       _exit(S_ERR);
     }
 
diff --git a/smtp.c b/smtp.c
index 32330aed0a30e48a3eee685b6563d4269e4b5088..e61b46696b7d14c2da7460bed40f91bd1fb3bf04 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -815,8 +815,7 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to,
     rc = 0;
   } while (false);
 
-  if (conn)
-    mutt_socket_close(conn);
+  mutt_socket_close(conn);
 
   if (rc == SMTP_ERR_READ)
     mutt_error(_("SMTP session failed: read error"));