From bb44b263f8301a7327c42bd389f48c4805ce5b51 Mon Sep 17 00:00:00 2001 From: Federico Kircheis Date: Tue, 6 Mar 2018 20:07:22 +0100 Subject: [PATCH] Reduce variable scope - pop_lib.c --- pop_lib.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pop_lib.c b/pop_lib.c index d4aa4ca7a85..75997fbe3b5 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -421,12 +421,12 @@ int pop_open_connection(struct PopData *pop_data) */ void pop_logout(struct Context *ctx) { - int ret = 0; - char buf[LONG_STRING]; struct PopData *pop_data = (struct PopData *) ctx->data; if (pop_data->status == POP_CONNECTED) { + int ret = 0; + char buf[LONG_STRING]; mutt_message(_("Closing connection to POP server...")); if (ctx->readonly) @@ -509,22 +509,20 @@ int pop_fetch_data(struct PopData *pop_data, char *query, struct Progress *progr int (*funct)(char *, void *), void *data) { char buf[LONG_STRING]; - char *inbuf = NULL; - char *p = NULL; - int ret, chunk = 0; long pos = 0; size_t lenbuf = 0; mutt_str_strfcpy(buf, query, sizeof(buf)); - ret = pop_query(pop_data, buf, sizeof(buf)); + int ret = pop_query(pop_data, buf, sizeof(buf)); if (ret < 0) return ret; - inbuf = mutt_mem_malloc(sizeof(buf)); + char *inbuf = mutt_mem_malloc(sizeof(buf)); while (true) { - chunk = mutt_socket_readln_d(buf, sizeof(buf), pop_data->conn, MUTT_SOCK_LOG_HDR); + const int chunk = + mutt_socket_readln_d(buf, sizeof(buf), pop_data->conn, MUTT_SOCK_LOG_HDR); if (chunk < 0) { pop_data->status = POP_DISCONNECTED; @@ -532,7 +530,7 @@ int pop_fetch_data(struct PopData *pop_data, char *query, struct Progress *progr break; } - p = buf; + char *p = buf; if (!lenbuf && buf[0] == '.') { if (buf[1] != '.') @@ -605,9 +603,7 @@ static int check_uidl(char *line, void *data) */ int pop_reconnect(struct Context *ctx) { - int ret; struct PopData *pop_data = (struct PopData *) ctx->data; - struct Progress progressbar; if (pop_data->status == POP_CONNECTED) return 0; @@ -618,9 +614,10 @@ int pop_reconnect(struct Context *ctx) { mutt_socket_close(pop_data->conn); - ret = pop_open_connection(pop_data); + int ret = pop_open_connection(pop_data); if (ret == 0) { + struct Progress progressbar; mutt_progress_init(&progressbar, _("Verifying message indexes..."), MUTT_PROGRESS_SIZE, NetInc, 0);