From: Federico Kircheis Date: Thu, 1 Mar 2018 17:03:51 +0000 (+0100) Subject: Reduce variable scope - attach.c X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcacf48d25a1af373db2746886561f82d051c667;p=neomutt Reduce variable scope - attach.c --- diff --git a/attach.c b/attach.c index b0bad4c90..2eaf12652 100644 --- 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; }