Commit e6831829 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

imap: remove duplicated function

The list and search response functions were identical! Merged into one
now. Detected by PVS Studio.

Reported-by: Alexis La Goutte
parent 0ee0d30a
Loading
Loading
Loading
Loading
+6 −30
Original line number Diff line number Diff line
@@ -1020,8 +1020,9 @@ static CURLcode imap_state_login_resp(struct connectdata *conn,
  return result;
}

/* For LIST responses */
static CURLcode imap_state_list_resp(struct connectdata *conn, int imapcode,
/* For LIST and SEARCH responses */
static CURLcode imap_state_listsearch_resp(struct connectdata *conn,
                                           int imapcode,
                                           imapstate instate)
{
  CURLcode result = CURLE_OK;
@@ -1249,31 +1250,6 @@ static CURLcode imap_state_append_final_resp(struct connectdata *conn,
  return result;
}

/* For SEARCH responses */
static CURLcode imap_state_search_resp(struct connectdata *conn, int imapcode,
                                       imapstate instate)
{
  CURLcode result = CURLE_OK;
  char *line = conn->data->state.buffer;
  size_t len = strlen(line);

  (void)instate; /* No use for this yet */

  if(imapcode == '*') {
    /* Temporarily add the LF character back and send as body to the client */
    line[len] = '\n';
    result = Curl_client_write(conn, CLIENTWRITE_BODY, line, len + 1);
    line[len] = '\0';
  }
  else if(imapcode != 'O')
    result = CURLE_QUOTE_ERROR; /* TODO: Fix error code */
  else
    /* End of DO phase */
    state(conn, IMAP_STOP);

  return result;
}

static CURLcode imap_statemach_act(struct connectdata *conn)
{
  CURLcode result = CURLE_OK;
@@ -1327,7 +1303,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
      break;

    case IMAP_LIST:
      result = imap_state_list_resp(conn, imapcode, imapc->state);
      result = imap_state_listsearch_resp(conn, imapcode, imapc->state);
      break;

    case IMAP_SELECT:
@@ -1351,7 +1327,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
      break;

    case IMAP_SEARCH:
      result = imap_state_search_resp(conn, imapcode, imapc->state);
      result = imap_state_listsearch_resp(conn, imapcode, imapc->state);
      break;

    case IMAP_LOGOUT: