]> granicus.if.org Git - neomutt/commitdiff
Reduce variable scope - attach.c
authorFederico Kircheis <federico.kircheis@gmail.com>
Thu, 1 Mar 2018 17:03:51 +0000 (18:03 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 3 Mar 2018 12:33:02 +0000 (12:33 +0000)
attach.c

index b0bad4c90e8dfd56275855761359c4f80c54b492..2eaf12652d31f358dbca93be197cb3ea198e28b4 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -307,12 +307,10 @@ bailout:
  */
 void mutt_check_lookup_list(struct Body *b, char *type, size_t len)
 {
-  int i;
-
   struct ListNode *np;
   STAILQ_FOREACH(np, &MimeLookupList, entries)
   {
-    i = mutt_str_strlen(np->data) - 1;
+    const int i = mutt_str_strlen(np->data) - 1;
     if ((i > 0 && np->data[i - 1] == '/' && np->data[i] == '*' &&
          (mutt_str_strncasecmp(type, np->data, i) == 0)) ||
         (mutt_str_strcasecmp(type, np->data) == 0))
@@ -1137,14 +1135,12 @@ int mutt_print_attachment(FILE *fp, struct Body *a)
 
 void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
 {
-  int i;
-
   if (actx->idxlen == actx->idxmax)
   {
     actx->idxmax += 5;
     mutt_mem_realloc(&actx->idx, sizeof(struct AttachPtr *) * actx->idxmax);
     mutt_mem_realloc(&actx->v2r, sizeof(short) * actx->idxmax);
-    for (i = actx->idxlen; i < actx->idxmax; i++)
+    for (int i = actx->idxlen; i < actx->idxmax; i++)
       actx->idx[i] = NULL;
   }
 
@@ -1153,13 +1149,11 @@ void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
 
 void mutt_actx_add_fp(struct AttachCtx *actx, FILE *new_fp)
 {
-  int i;
-
   if (actx->fp_len == actx->fp_max)
   {
     actx->fp_max += 5;
     mutt_mem_realloc(&actx->fp_idx, sizeof(FILE *) * actx->fp_max);
-    for (i = actx->fp_len; i < actx->fp_max; i++)
+    for (int i = actx->fp_len; i < actx->fp_max; i++)
       actx->fp_idx[i] = NULL;
   }
 
@@ -1168,13 +1162,11 @@ void mutt_actx_add_fp(struct AttachCtx *actx, FILE *new_fp)
 
 void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body)
 {
-  int i;
-
   if (actx->body_len == actx->body_max)
   {
     actx->body_max += 5;
     mutt_mem_realloc(&actx->body_idx, sizeof(struct Body *) * actx->body_max);
-    for (i = actx->body_len; i < actx->body_max; i++)
+    for (int i = actx->body_len; i < actx->body_max; i++)
       actx->body_idx[i] = NULL;
   }