]> granicus.if.org Git - neomutt/commitdiff
Reduce variable scope - pop_lib.c
authorFederico Kircheis <federico.kircheis@gmail.com>
Tue, 6 Mar 2018 19:07:22 +0000 (20:07 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 8 Mar 2018 02:27:15 +0000 (02:27 +0000)
pop_lib.c

index d4aa4ca7a859aee07914389e8f86b6d57c2e9852..75997fbe3b5efec881ab6976c00f2423eddb702c 100644 (file)
--- a/pop_lib.c
+++ b/pop_lib.c
@@ -421,12 +421,12 @@ err_conn:
  */
 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);