Skip to content

Commit

Permalink
Reduce variable scope - pop_lib.c
Browse files Browse the repository at this point in the history
  • Loading branch information
fekir authored and flatcap committed Mar 8, 2018
1 parent fceb080 commit bb44b26
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pop_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -509,30 +509,28 @@ 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;
ret = -1;
break;
}

p = buf;
char *p = buf;
if (!lenbuf && buf[0] == '.')
{
if (buf[1] != '.')
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit bb44b26

Please sign in to comment.