]> granicus.if.org Git - neomutt/commitdiff
minor tidying/boolification
authorRichard Russon <rich@flatcap.org>
Wed, 29 Nov 2017 00:13:59 +0000 (00:13 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 29 Nov 2017 00:29:10 +0000 (00:29 +0000)
address.c
address.h
alias.c
group.c
main.c
mbox.c
ncrypt/crypt.c
query.c
send.c
sendlib.c

index 4b58b0b4827d7aeaebb654edcdc897b25880a5bb..07421c6720b315ef7a3d7460e3707233b9574b4d 100644 (file)
--- a/address.c
+++ b/address.c
@@ -104,11 +104,13 @@ struct Address *mutt_addr_new(void)
  *
  * @note This doesn't alter the links if the Address is in a list.
  */
-static void free_address(struct Address *a)
+static void free_address(struct Address **a)
 {
-  FREE(&a->personal);
-  FREE(&a->mailbox);
-  FREE(&a);
+  if (!a || !*a)
+    return;
+  FREE(&(*a)->personal);
+  FREE(&(*a)->mailbox);
+  FREE(&(*a));
 }
 
 /**
@@ -135,7 +137,7 @@ int mutt_addr_remove_from_list(struct Address **a, const char *mailbox)
         (*a) = p->next;
       t = p;
       p = p->next;
-      free_address(t);
+      free_address(&t);
       rc = 0;
     }
     else
@@ -160,9 +162,7 @@ void mutt_addr_free(struct Address **p)
   {
     t = *p;
     *p = (*p)->next;
-    FREE(&t->personal);
-    FREE(&t->mailbox);
-    FREE(&t);
+    free_address(&t);
   }
 }
 
@@ -757,7 +757,7 @@ struct Address *mutt_addr_copy(struct Address *addr)
  * @param prune Skip groups if there are more addresses
  * @retval ptr New Address list
  */
-struct Address *mutt_addr_copy_list(struct Address *addr, int prune)
+struct Address *mutt_addr_copy_list(struct Address *addr, bool prune)
 {
   struct Address *top = NULL, *last = NULL;
 
@@ -787,7 +787,7 @@ struct Address *mutt_addr_copy_list(struct Address *addr, int prune)
  *
  * Append the Source onto the end of the Destination Address list.
  */
-struct Address *mutt_addr_append(struct Address **a, struct Address *b, int prune)
+struct Address *mutt_addr_append(struct Address **a, struct Address *b, bool prune)
 {
   struct Address *tmp = *a;
 
@@ -861,23 +861,23 @@ bool mutt_addr_valid_msgid(const char *msgid)
  * @param b Second Address
  * @retval true Address lists are strictly identical
  */
-int mutt_addr_cmp_strict(const struct Address *a, const struct Address *b)
+bool mutt_addr_cmp_strict(const struct Address *a, const struct Address *b)
 {
   while (a && b)
   {
     if ((mutt_str_strcmp(a->mailbox, b->mailbox) != 0) ||
         (mutt_str_strcmp(a->personal, b->personal) != 0))
     {
-      return 0;
+      return false;
     }
 
     a = a->next;
     b = b->next;
   }
   if (a || b)
-    return 0;
+    return false;
 
-  return 1;
+  return true;
 }
 
 /**
@@ -921,12 +921,12 @@ bool mutt_addr_cmp(struct Address *a, struct Address *b)
  * @param lst Address List
  * @retval true If the Address is in the list
  */
-int mutt_addr_search(struct Address *a, struct Address *lst)
+bool mutt_addr_search(struct Address *a, struct Address *lst)
 {
   for (; lst; lst = lst->next)
   {
     if (mutt_addr_cmp(a, lst))
-      return 1;
+      return true;
   }
-  return 0;
+  return false;
 }
index e0f8a8f1d59fd667ebbd09a8b146a5133812e366..67f62e0da205298715cd62115654f81d4495a2cc 100644 (file)
--- a/address.h
+++ b/address.h
@@ -57,11 +57,11 @@ extern const char AddressSpecials[];
 
 #define address_error(x) AddressErrors[x]
 
-struct Address *mutt_addr_append(struct Address **a, struct Address *b, int prune);
+struct Address *mutt_addr_append(struct Address **a, struct Address *b, bool prune);
 void            mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials);
-int             mutt_addr_cmp_strict(const struct Address *a, const struct Address *b);
+bool            mutt_addr_cmp_strict(const struct Address *a, const struct Address *b);
 bool            mutt_addr_cmp(struct Address *a, struct Address *b);
-struct Address *mutt_addr_copy_list(struct Address *addr, int prune);
+struct Address *mutt_addr_copy_list(struct Address *addr, bool prune);
 struct Address *mutt_addr_copy(struct Address *addr);
 void            mutt_addr_free(struct Address **p);
 int             mutt_addr_has_recips(struct Address *a);
@@ -70,7 +70,7 @@ struct Address *mutt_addr_parse_list2(struct Address *p, const char *s);
 struct Address *mutt_addr_parse_list(struct Address *top, const char *s);
 void            mutt_addr_qualify(struct Address *addr, const char *host);
 int             mutt_addr_remove_from_list(struct Address **a, const char *mailbox);
-int             mutt_addr_search(struct Address *a, struct Address *lst);
+bool            mutt_addr_search(struct Address *a, struct Address *lst);
 bool            mutt_addr_valid_msgid(const char *msgid);
 
 #endif /* _MUTT_ADDRESS_H */
diff --git a/alias.c b/alias.c
index 9a0bf1457c3ad6f15ecc82626cd32f799932d83e..cb333d4d7e3d759a1477c65c88a17f099a10c225 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -83,7 +83,7 @@ static struct Address *expand_aliases_r(struct Address *a, struct ListHead *expn
         if (!i)
         {
           mutt_list_insert_head(expn, mutt_str_strdup(a->mailbox));
-          w = mutt_addr_copy_list(t, 0);
+          w = mutt_addr_copy_list(t, false);
           w = expand_aliases_r(w, expn);
           if (head)
             last->next = w;
diff --git a/group.c b/group.c
index 01897218bdfcfc0af26423c9096034b356124c35..f0640e51b359cdc8e2d0bc9cc2d62e4291625ef5 100644 (file)
--- a/group.c
+++ b/group.c
@@ -113,7 +113,7 @@ static void group_add_adrlist(struct Group *g, struct Address *a)
   for (p = &g->as; *p; p = &((*p)->next))
     ;
 
-  q = mutt_addr_copy_list(a, 0);
+  q = mutt_addr_copy_list(a, false);
   q = mutt_remove_xrefs(g->as, q);
   *p = q;
 }
diff --git a/main.c b/main.c
index b6b2d31d93905385d9d5d1696793864aacf94b0f..dc7df58b4e5569335131dcca7d7cb2e7059347e1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -728,9 +728,9 @@ int main(int argc, char **argv, char **env)
           }
         }
 
-        mutt_addr_append(&msg->env->to, opts_env->to, 0);
-        mutt_addr_append(&msg->env->cc, opts_env->cc, 0);
-        mutt_addr_append(&msg->env->bcc, opts_env->bcc, 0);
+        mutt_addr_append(&msg->env->to, opts_env->to, false);
+        mutt_addr_append(&msg->env->cc, opts_env->cc, false);
+        mutt_addr_append(&msg->env->bcc, opts_env->bcc, false);
         if (opts_env->subject)
           mutt_str_replace(&msg->env->subject, opts_env->subject);
 
diff --git a/mbox.c b/mbox.c
index efe5d1250038f4b9bee71fbd366b5618a25bad27..b935d152ce144a2faa0603f909f37209b20a4f4c 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -219,7 +219,7 @@ static int mmdf_parse_mailbox(struct Context *ctx)
         hdr->env->return_path = mutt_addr_parse_list(hdr->env->return_path, return_path);
 
       if (!hdr->env->from)
-        hdr->env->from = mutt_addr_copy_list(hdr->env->return_path, 0);
+        hdr->env->from = mutt_addr_copy_list(hdr->env->return_path, false);
 
       ctx->msgcount++;
     }
@@ -391,7 +391,7 @@ static int mbox_parse_mailbox(struct Context *ctx)
             mutt_addr_parse_list(curhdr->env->return_path, return_path);
 
       if (!curhdr->env->from)
-        curhdr->env->from = mutt_addr_copy_list(curhdr->env->return_path, 0);
+        curhdr->env->from = mutt_addr_copy_list(curhdr->env->return_path, false);
 
       lines = 0;
     }
index 43735dd8bb18a8344064a75ab0c3b677c9445838..f163d3d22b1ac7c1951c14bdb20bb92ab3213ee0 100644 (file)
@@ -853,9 +853,9 @@ int crypt_get_keys(struct Header *msg, char **keylist, int oppenc_mode)
   if ((WithCrypto & APPLICATION_PGP))
     set_option(OPT_PGP_CHECK_TRUST);
 
-  last = mutt_addr_append(&adrlist, msg->env->to, 0);
-  last = mutt_addr_append(last ? &last : &adrlist, msg->env->cc, 0);
-  mutt_addr_append(last ? &last : &adrlist, msg->env->bcc, 0);
+  last = mutt_addr_append(&adrlist, msg->env->to, false);
+  last = mutt_addr_append(last ? &last : &adrlist, msg->env->cc, false);
+  mutt_addr_append(last ? &last : &adrlist, msg->env->bcc, false);
 
   if (fqdn)
     mutt_addr_qualify(adrlist, fqdn);
diff --git a/query.c b/query.c
index f43f50554d5b7fda84bf497d017f6b4a473b02f0..d9664783450ed7214c80623af09846b6e871e773 100644 (file)
--- a/query.c
+++ b/query.c
@@ -81,7 +81,7 @@ static struct Address *result_to_addr(struct Query *r)
 {
   static struct Address *tmp = NULL;
 
-  tmp = mutt_addr_copy_list(r->addr, 0);
+  tmp = mutt_addr_copy_list(r->addr, false);
   if (!tmp)
     return NULL;
 
@@ -438,7 +438,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb
               if (QueryTable[i].tagged)
               {
                 struct Address *a = result_to_addr(QueryTable[i].data);
-                mutt_addr_append(&naddr, a, 0);
+                mutt_addr_append(&naddr, a, false);
                 mutt_addr_free(&a);
               }
             }
@@ -474,7 +474,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb
               if (QueryTable[i].tagged)
               {
                 struct Address *a = result_to_addr(QueryTable[i].data);
-                mutt_addr_append(&msg->env->to, a, 0);
+                mutt_addr_append(&msg->env->to, a, false);
                 mutt_addr_free(&a);
               }
           }
diff --git a/send.c b/send.c
index 911273ef3d251fe5c3ebb86a7278efa2d05d57bf..749d98a31df11434efae6428a6a3be13afb0704a 100644 (file)
--- a/send.c
+++ b/send.c
@@ -510,7 +510,7 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int
 
   if (flags && env->mail_followup_to && hmfupto == MUTT_YES)
   {
-    mutt_addr_append(to, env->mail_followup_to, 1);
+    mutt_addr_append(to, env->mail_followup_to, true);
     return 0;
   }
 
@@ -523,7 +523,7 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int
   if (!option(OPT_REPLY_SELF) && mutt_addr_is_user(env->from))
   {
     /* mail is from the user, assume replying to recipients */
-    mutt_addr_append(to, env->to, 1);
+    mutt_addr_append(to, env->to, true);
   }
   else if (env->reply_to)
   {
@@ -541,7 +541,7 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int
        * in his From header, and the reply-to has no display-name.
        *
        */
-      mutt_addr_append(to, env->from, 0);
+      mutt_addr_append(to, env->from, false);
     }
     else if (!(mutt_addr_cmp(env->from, env->reply_to) && !env->reply_to->next) &&
              quadoption(OPT_REPLY_TO) != MUTT_YES)
@@ -559,11 +559,11 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int
       switch (query_quadoption(OPT_REPLY_TO, prompt))
       {
         case MUTT_YES:
-          mutt_addr_append(to, env->reply_to, 0);
+          mutt_addr_append(to, env->reply_to, false);
           break;
 
         case MUTT_NO:
-          mutt_addr_append(to, env->from, 0);
+          mutt_addr_append(to, env->from, false);
           break;
 
         default:
@@ -571,10 +571,10 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int
       }
     }
     else
-      mutt_addr_append(to, env->reply_to, 0);
+      mutt_addr_append(to, env->reply_to, false);
   }
   else
-    mutt_addr_append(to, env->from, 0);
+    mutt_addr_append(to, env->from, false);
 
   return 0;
 }
@@ -599,7 +599,7 @@ int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags)
   if (flags & SENDLISTREPLY)
   {
     tmp = find_mailing_lists(in->to, in->cc);
-    mutt_addr_append(&out->to, tmp, 0);
+    mutt_addr_append(&out->to, tmp, false);
     mutt_addr_free(&tmp);
 
     if (in->mail_followup_to && hmfupto == MUTT_YES &&
@@ -616,8 +616,8 @@ int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags)
     if ((flags & SENDGROUPREPLY) && (!in->mail_followup_to || hmfupto != MUTT_YES))
     {
       /* if(!mutt_addr_is_user(in->to)) */
-      mutt_addr_append(&out->cc, in->to, 1);
-      mutt_addr_append(&out->cc, in->cc, 1);
+      mutt_addr_append(&out->cc, in->to, true);
+      mutt_addr_append(&out->cc, in->cc, true);
     }
   }
   return 0;
@@ -961,8 +961,8 @@ void mutt_set_followup_to(struct Envelope *e)
        * mail-followup-to header
        */
 
-      t = mutt_addr_append(&e->mail_followup_to, e->to, 0);
-      mutt_addr_append(&t, e->cc, 1);
+      t = mutt_addr_append(&e->mail_followup_to, e->to, false);
+      mutt_addr_append(&t, e->cc, true);
     }
 
     /* remove ourselves from the mail-followup-to header */
@@ -978,9 +978,9 @@ void mutt_set_followup_to(struct Envelope *e)
     if (e->mail_followup_to && !mutt_is_list_recipient(0, e->to, e->cc))
     {
       if (e->reply_to)
-        from = mutt_addr_copy_list(e->reply_to, 0);
+        from = mutt_addr_copy_list(e->reply_to, false);
       else if (e->from)
-        from = mutt_addr_copy_list(e->from, 0);
+        from = mutt_addr_copy_list(e->from, false);
       else
         from = mutt_default_from();
 
@@ -1189,11 +1189,11 @@ int mutt_compose_to_sender(struct Header *hdr)
     for (int i = 0; i < Context->msgcount; i++)
     {
       if (message_is_tagged(Context, i))
-        mutt_addr_append(&msg->env->to, Context->hdrs[i]->env->from, 0);
+        mutt_addr_append(&msg->env->to, Context->hdrs[i]->env->from, false);
     }
   }
   else
-    msg->env->to = mutt_addr_copy_list(hdr->env->from, 0);
+    msg->env->to = mutt_addr_copy_list(hdr->env->from, false);
 
   return ci_send_message(0, msg, NULL, NULL, NULL);
 }
index c36cef97611126d7c613e861260831f2c220b2f0..19df360cb741f16b73549808c3ff92f732c76a5a 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2821,7 +2821,7 @@ int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to)
    * function is called, since the user receives confirmation of the address
    * list being bounced to.
    */
-  resent_to = mutt_addr_copy_list(to, 0);
+  resent_to = mutt_addr_copy_list(to, false);
   rfc2047_encode_adrlist(resent_to, "Resent-To");
 
   ret = bounce_message(fp, h, resent_to, resent_from, from);