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

Curl_setup_transfer: no longer returns anything

This function could only return CURLE_OK and by changing it to
a void instead, we can simplify code all over.
parent 93981bb9
Loading
Loading
Loading
Loading
+13 −18
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -217,14 +217,13 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)

    free(eword);

    if(result)
    if(result) {
      failf(data, "Failed sending DICT request");
    else
      result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
                                   -1, NULL); /* no upload */
    if(result)
      return result;
    }
    Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
                        -1, NULL); /* no upload */
  }
  else if(Curl_raw_nequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
           Curl_raw_nequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
           Curl_raw_nequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
@@ -265,15 +264,12 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)

    free(eword);

    if(result)
    if(result) {
      failf(data, "Failed sending DICT request");
    else
      result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
                                   -1, NULL); /* no upload */

    if(result)
      return result;

    }
    Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
                        -1, NULL); /* no upload */
  }
  else {

@@ -290,14 +286,13 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
                          "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
                          "%s\r\n"
                          "QUIT\r\n", ppath);
      if(result)
      if(result) {
        failf(data, "Failed sending DICT request");
      else
        result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
                                     -1, NULL);
      if(result)
        return result;
      }

      Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, -1, NULL);
    }
  }

  return CURLE_OK;
+8 −11
Original line number Diff line number Diff line
@@ -1378,7 +1378,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
        infof(data, "File already completely uploaded\n");

        /* no data to transfer */
        result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
        Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);

        /* Set ->transfer so that we won't get any error in
         * ftp_done() because we didn't transfer anything! */
@@ -1974,7 +1974,7 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn,

    if(ftp->downloadsize == 0) {
      /* no data to transfer */
      result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
      Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
      infof(data, "File already completely downloaded\n");

      /* Set ->transfer so that we won't get any error in ftp_done()
@@ -2116,7 +2116,7 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn,
  /* set the SO_SNDBUF for the secondary socket for those who need it */
  Curl_sndbufset(conn->sock[SECONDARYSOCKET]);

  result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */
  Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */
                      SECONDARYSOCKET, ftp->bytecountp);
  state(conn, FTP_STOP);

@@ -2230,11 +2230,8 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
      infof(data, "Getting file with size: %" FORMAT_OFF_T "\n", size);

    /* FTP download: */
    result=Curl_setup_transfer(conn, SECONDARYSOCKET, size, FALSE,
                               ftp->bytecountp,
                               -1, NULL); /* no upload here */
    if(result)
      return result;
    Curl_setup_transfer(conn, SECONDARYSOCKET, size, FALSE,
                        ftp->bytecountp, -1, NULL); /* no upload here */

    conn->proto.ftpc.pp.pending_resp = TRUE; /* expect server response */
    state(conn, FTP_STOP);
@@ -3391,7 +3388,7 @@ static CURLcode ftp_nextconnect(struct connectdata *conn)
  if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY))
    /* no data to transfer. FIX: it feels like a kludge to have this here
       too! */
    result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
    Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);

  /* end of transfer */
  DEBUGF(infof(data, "DO-MORE phase ends with %d\n", (int)result));
@@ -3818,7 +3815,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn,

  if(ftp->transfer != FTPTRANSFER_BODY)
    /* no data to transfer */
    result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
    Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
  else if(!connected)
    /* since we didn't connect now, we want do_more to get called */
    conn->bits.do_more = TRUE;
+15 −21
Original line number Diff line number Diff line
@@ -2658,8 +2658,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
        failf(data, "Failed sending POST request");
      else
        /* setup variables for the upcoming transfer */
        result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
                                     &http->readbytecount,
        Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount,
                            -1, NULL);
      break;
    }
@@ -2728,9 +2727,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
      failf(data, "Failed sending POST request");
    else
      /* setup variables for the upcoming transfer */
      result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
                                   &http->readbytecount,
                                   FIRSTSOCKET,
      Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
                          &http->readbytecount, FIRSTSOCKET,
                          &http->writebytecount);

    if(result) {
@@ -2781,9 +2779,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
      failf(data, "Failed sending PUT request");
    else
      /* prepare for transfer */
      result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
                                   &http->readbytecount,
                                   postsize?FIRSTSOCKET:-1,
      Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
                          &http->readbytecount, postsize?FIRSTSOCKET:-1,
                          postsize?&http->writebytecount:NULL);
    if(result)
      return result;
@@ -2931,10 +2928,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
    if(result)
      failf(data, "Failed sending HTTP POST request");
    else
      result =
      Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
                            &http->readbytecount,
                            http->postdata?FIRSTSOCKET:-1,
                          &http->readbytecount, http->postdata?FIRSTSOCKET:-1,
                          http->postdata?&http->writebytecount:NULL);
    break;

@@ -2951,8 +2946,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
      failf(data, "Failed sending HTTP request");
    else
      /* HTTP GET/HEAD download: */
      result = Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
                                   &http->readbytecount,
      Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount,
                          http->postdata?FIRSTSOCKET:-1,
                          http->postdata?&http->writebytecount:NULL);
  }
+5 −7
Original line number Diff line number Diff line
@@ -436,12 +436,11 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn,

    if(!filesize)
      /* the entire data is already transfered! */
      result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
      Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
    else
      /* IMAP download */
      result=Curl_setup_transfer(conn, FIRSTSOCKET, filesize, FALSE,
                                 imap->bytecountp,
                                 -1, NULL); /* no upload here */
      Curl_setup_transfer(conn, FIRSTSOCKET, filesize, FALSE,
                          imap->bytecountp, -1, NULL); /* no upload here */

    data->req.maxdownload = filesize;
  }
@@ -924,15 +923,14 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
static CURLcode imap_dophase_done(struct connectdata *conn,
                                  bool connected)
{
  CURLcode result = CURLE_OK;
  struct FTP *imap = conn->data->state.proto.imap;
  (void)connected;

  if(imap->transfer != FTPTRANSFER_BODY)
    /* no data to transfer */
    result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
    Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);

  return result;
  return CURLE_OK;
}

/* called from multi.c while DOing */
+7 −10
Original line number Diff line number Diff line
@@ -359,9 +359,8 @@ static CURLcode pop3_state_retr_resp(struct connectdata *conn,
  }

  /* POP3 download */
  result=Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE,
                             pop3->bytecountp,
                             -1, NULL); /* no upload here */
  Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE,
                      pop3->bytecountp, -1, NULL); /* no upload here */

  if(pp->cache) {
    /* At this point there is a bunch of data in the header "cache" that is
@@ -403,8 +402,7 @@ static CURLcode pop3_state_list_resp(struct connectdata *conn,
  }

  /* POP3 download */
  result=Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE,
                             pop3->bytecountp,
  Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, pop3->bytecountp,
                      -1, NULL); /* no upload here */

  if(pp->cache) {
@@ -863,18 +861,17 @@ static CURLcode pop3_parse_url_path(struct connectdata *conn)
static CURLcode pop3_dophase_done(struct connectdata *conn,
                                  bool connected)
{
  CURLcode result = CURLE_OK;
  struct FTP *pop3 = conn->data->state.proto.pop3;
  struct pop3_conn *pop3c = &conn->proto.pop3c;
  (void)connected;

  if(pop3->transfer != FTPTRANSFER_BODY)
    /* no data to transfer */
    result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
    Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);

  free(pop3c->mailbox);

  return result;
  return CURLE_OK;
}

/* called from multi.c while DOing */
Loading