Commit a5021071 authored by Yang Tse's avatar Yang Tse
Browse files

fix bool variables checking and assignment

parent eb44ac01
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ static bool tailmatch(const char *little, const char *bigone)
  if(littlelen > biglen)
    return FALSE;

  return (bool)Curl_raw_equal(little, bigone+biglen-littlelen);
  return Curl_raw_equal(little, bigone+biglen-littlelen) ? TRUE : FALSE;
}

/*
@@ -241,7 +241,7 @@ Curl_cookie_add(struct SessionHandle *data,
          endofn++;

        /* name ends with a '=' ? */
        sep = *endofn == '='?TRUE:FALSE;
        sep = (*endofn == '=')?TRUE:FALSE;

        /* Strip off trailing whitespace from the 'what' */
        while(len && ISBLANK(what[len-1])) {
@@ -527,7 +527,7 @@ Curl_cookie_add(struct SessionHandle *data,
           As far as I can see, it is set to true when the cookie says
           .domain.com and to false when the domain is complete www.domain.com
        */
        co->tailmatch=(bool)Curl_raw_equal(ptr, "TRUE");
        co->tailmatch = Curl_raw_equal(ptr, "TRUE")?TRUE:FALSE;
        break;
      case 2:
        /* It turns out, that sometimes the file format allows the path
@@ -547,7 +547,7 @@ Curl_cookie_add(struct SessionHandle *data,
        fields++; /* add a field and fall down to secure */
        /* FALLTHROUGH */
      case 3:
        co->secure = (bool)Curl_raw_equal(ptr, "TRUE");
        co->secure = Curl_raw_equal(ptr, "TRUE")?TRUE:FALSE;
        break;
      case 4:
        co->expires = curlx_strtoofft(ptr, NULL, 10);
+1 −1
Original line number Diff line number Diff line
@@ -413,7 +413,7 @@ int Curl_cyassl_init(void)
bool Curl_cyassl_data_pending(const struct connectdata* conn, int connindex)
{
  if(conn->ssl[connindex].handle)   /* SSL is in use */
    return (bool)(0 != SSL_pending(conn->ssl[connindex].handle));
    return (0 != SSL_pending(conn->ssl[connindex].handle)) ? TRUE : FALSE;
  else
    return FALSE;
}
+1 −1
Original line number Diff line number Diff line
@@ -1273,7 +1273,7 @@ static size_t readfromfile(struct Form *form, char *buffer,
                           size_t size)
{
  size_t nread;
  bool callback = (bool)(form->data->type == FORM_CALLBACK);
  bool callback = (form->data->type == FORM_CALLBACK)?TRUE:FALSE;

  if(callback) {
    if(form->fread_func == ZERO_NULL)
+6 −6
Original line number Diff line number Diff line
@@ -298,8 +298,8 @@ static void freedirs(struct ftp_conn *ftpc)
*/
static bool isBadFtpString(const char *string)
{
  return (bool)((NULL != strchr(string, '\r')) ||
                (NULL != strchr(string, '\n')));
  return ((NULL != strchr(string, '\r')) ||
          (NULL != strchr(string, '\n'))) ? TRUE : FALSE;
}

/***********************************************************************
@@ -2530,7 +2530,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
      if(ftpcode/100 == 2)
        /* We have enabled SSL for the data connection! */
        conn->ssl[SECONDARYSOCKET].use =
          (bool)(data->set.ftp_ssl != CURLUSESSL_CONTROL);
          (data->set.ftp_ssl != CURLUSESSL_CONTROL) ? TRUE : FALSE;
      /* FTP servers typically responds with 500 if they decide to reject
         our 'P' request */
      else if(data->set.ftp_ssl > CURLUSESSL_CONTROL)
@@ -2841,7 +2841,7 @@ static CURLcode ftp_multi_statemach(struct connectdata *conn,
  /* Check for the state outside of the Curl_socket_ready() return code checks
     since at times we are in fact already in this state when this function
     gets called. */
  *done = (bool)(ftpc->state == FTP_STOP);
  *done = (ftpc->state == FTP_STOP) ? TRUE : FALSE;

  return result;
}
@@ -2895,9 +2895,9 @@ static CURLcode ftp_init(struct connectdata *conn)
  */
  ftp->user = conn->user;
  ftp->passwd = conn->passwd;
  if(TRUE == isBadFtpString(ftp->user))
  if(isBadFtpString(ftp->user))
    return CURLE_URL_MALFORMAT;
  if(TRUE == isBadFtpString(ftp->passwd))
  if(isBadFtpString(ftp->passwd))
    return CURLE_URL_MALFORMAT;

  conn->proto.ftpc.known_filesize = -1; /* unknown size for now */
+10 −10
Original line number Diff line number Diff line
@@ -588,7 +588,7 @@ output_auth_headers(struct connectdata *conn,
          proxy?"Proxy":"Server", auth,
          proxy?(conn->proxyuser?conn->proxyuser:""):
                (conn->user?conn->user:""));
    authstatus->multi = (bool)(!authstatus->done);
    authstatus->multi = (!authstatus->done) ? TRUE : FALSE;
  }
  else
    authstatus->multi = FALSE;
@@ -745,7 +745,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
      data->state.authproblem = TRUE;
    }
    else {
      neg = Curl_input_negotiate(conn, (bool)(httpcode == 407), start);
      neg = Curl_input_negotiate(conn, (httpcode == 407)?TRUE:FALSE, start);
      if(neg == 0) {
        DEBUGASSERT(!data->req.newurl);
        data->req.newurl = strdup(data->change.url);
@@ -771,7 +771,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
         authp->picked == CURLAUTH_NTLM_WB) {
        /* NTLM authentication is picked and activated */
        CURLcode ntlm =
          Curl_input_ntlm(conn, (bool)(httpcode == 407), start);
          Curl_input_ntlm(conn, (httpcode == 407)?TRUE:FALSE, start);
        if(CURLE_OK == ntlm) {
          data->state.authproblem = FALSE;
#ifdef NTLM_WB_ENABLED
@@ -817,7 +817,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
          /* We call this function on input Digest headers even if Digest
           * authentication isn't activated yet, as we need to store the
           * incoming data from this header in case we are gonna use Digest. */
          dig = Curl_input_digest(conn, (bool)(httpcode == 407), start);
          dig = Curl_input_digest(conn, (httpcode == 407)?TRUE:FALSE, start);

          if(CURLDIGEST_FINE != dig) {
            infof(data, "Authentication problem. Ignoring this.\n");
@@ -946,7 +946,7 @@ static size_t readmoredata(char *buffer,
    return 0;

  /* make sure that a HTTP request is never sent away chunked! */
  conn->data->req.forbidchunk = (bool)(http->sending == HTTPSEND_REQUEST);
  conn->data->req.forbidchunk = (http->sending == HTTPSEND_REQUEST)?TRUE:FALSE;

  if(http->postsize <= (curl_off_t)fullsize) {
    memcpy(buffer, http->postdata, (size_t)http->postsize);
@@ -1479,11 +1479,11 @@ CURLcode Curl_http_done(struct connectdata *conn,
static bool use_http_1_1(const struct SessionHandle *data,
                         const struct connectdata *conn)
{
  return (bool)((data->set.httpversion == CURL_HTTP_VERSION_1_1) ||
  return ((data->set.httpversion == CURL_HTTP_VERSION_1_1) ||
         ((data->set.httpversion != CURL_HTTP_VERSION_1_0) &&
          ((conn->httpversion == 11) ||
           ((conn->httpversion != 10) &&
            (data->state.httpversion != 10)))));
            (data->state.httpversion != 10))))) ? TRUE : FALSE;
}

/* check and possibly add an Expect: header */
@@ -2154,8 +2154,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
                               conn->allocptr.cookiehost?
                               conn->allocptr.cookiehost:host,
                               data->state.path,
                               (bool)(conn->handler->protocol&CURLPROTO_HTTPS?
                                      TRUE:FALSE));
                               (conn->handler->protocol&CURLPROTO_HTTPS)?
                               TRUE:FALSE);
      Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
    }
    if(co) {
@@ -2582,7 +2582,7 @@ checkhttpprefix(struct SessionHandle *data,
    head = head->next;
  }

  if((rc != TRUE) && (checkprefix("HTTP/", s)))
  if(!rc && (checkprefix("HTTP/", s)))
    rc = TRUE;

#ifdef CURL_DOES_CONVERSIONS
Loading