Permalink
Browse files

fix bool variables checking and assignment

  • Loading branch information...
1 parent eb44ac0 commit a50210710ab6fd772e2762ed36602c15adfb49e1 @yangtse yangtse committed Sep 5, 2011
Showing with 128 additions and 129 deletions.
  1. +4 −4 lib/cookie.c
  2. +1 −1 lib/cyassl.c
  3. +1 −1 lib/formdata.c
  4. +6 −6 lib/ftp.c
  5. +10 −10 lib/http.c
  6. +3 −3 lib/http_chunks.c
  7. +1 −1 lib/imap.c
  8. +9 −8 lib/multi.c
  9. +6 −7 lib/nonblock.c
  10. +1 −1 lib/pop3.c
  11. +3 −3 lib/sendf.c
  12. +1 −1 lib/smtp.c
  13. +1 −1 lib/socks.c
  14. +1 −1 lib/ssh.c
  15. +3 −3 lib/sslgen.c
  16. +3 −3 lib/ssluse.c
  17. +1 −1 lib/telnet.c
  18. +3 −3 lib/tftp.c
  19. +4 −4 lib/transfer.c
  20. +53 −54 lib/url.c
  21. +11 −11 src/main.c
  22. +1 −1 src/writeout.c
  23. +1 −1 tests/server/fake_ntlm.c
View
@@ -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);
View
@@ -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;
}
View
@@ -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)
View
@@ -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 */
View
@@ -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
View
@@ -79,9 +79,9 @@
We avoid the use of isxdigit to accommodate non-ASCII hosts. */
static bool Curl_isxdigit(char digit)
{
- return (bool)( (digit >= 0x30 && digit <= 0x39) /* 0-9 */
- || (digit >= 0x41 && digit <= 0x46) /* A-F */
- || (digit >= 0x61 && digit <= 0x66) ); /* a-f */
+ return ( (digit >= 0x30 && digit <= 0x39) /* 0-9 */
+ || (digit >= 0x41 && digit <= 0x46) /* A-F */
+ || (digit >= 0x61 && digit <= 0x66) /* a-f */ ) ? TRUE : FALSE;
}
void Curl_httpchunk_init(struct connectdata *conn)
View
@@ -630,7 +630,7 @@ static CURLcode imap_multi_statemach(struct connectdata *conn,
else
result = Curl_pp_multi_statemach(&imapc->pp);
- *done = (bool)(imapc->state == IMAP_STOP);
+ *done = (imapc->state == IMAP_STOP) ? TRUE : FALSE;
return result;
}
View
@@ -628,9 +628,10 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
easy = data->multi_pos;
if(easy) {
- bool premature = (bool)(easy->state < CURLM_STATE_COMPLETED);
- bool easy_owns_conn = (bool)(easy->easy_conn &&
- (easy->easy_conn->data == easy->easy_handle));
+ bool premature = (easy->state < CURLM_STATE_COMPLETED) ? TRUE : FALSE;
+ bool easy_owns_conn = (easy->easy_conn &&
+ (easy->easy_conn->data == easy->easy_handle)) ?
+ TRUE : FALSE;
/* If the 'state' is not INIT or COMPLETED, we might need to do something
nice to put the easy_handle in a good known state when this returns. */
@@ -1282,7 +1283,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
disconnect_conn = TRUE;
}
else
- retry = (bool)(newurl?TRUE:FALSE);
+ retry = (newurl)?TRUE:FALSE;
Curl_posttransfer(data);
drc = Curl_done(&easy->easy_conn, easy->result, FALSE);
@@ -1481,14 +1482,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
Curl_posttransfer(data);
Curl_done(&easy->easy_conn, easy->result, FALSE);
}
- else if(TRUE == done) {
+ else if(done) {
char *newurl = NULL;
bool retry = FALSE;
followtype follow=FOLLOW_NONE;
easy->result = Curl_retry_request(easy->easy_conn, &newurl);
if(!easy->result)
- retry = (bool)(newurl?TRUE:FALSE);
+ retry = (newurl)?TRUE:FALSE;
/* call this even if the readwrite function returned error */
Curl_posttransfer(data);
@@ -2213,7 +2214,7 @@ CURLMcode curl_multi_setopt(CURLM *multi_handle,
multi->socket_userp = va_arg(param, void *);
break;
case CURLMOPT_PIPELINING:
- multi->pipelining_enabled = (bool)(0 != va_arg(param, long));
+ multi->pipelining_enabled = (0 != va_arg(param, long)) ? TRUE : FALSE;
break;
case CURLMOPT_TIMERFUNCTION:
multi->timer_cb = va_arg(param, curl_multi_timer_callback);
@@ -2478,7 +2479,7 @@ static bool isHandleAtHead(struct SessionHandle *handle,
{
struct curl_llist_element *curr = pipeline->head;
if(curr)
- return (bool)(curr->ptr == handle);
+ return (curr->ptr == handle) ? TRUE : FALSE;
return FALSE;
}
View
@@ -62,34 +62,33 @@ int curlx_nonblock(curl_socket_t sockfd, /* operate on this */
/* most recent unix versions */
int flags;
flags = fcntl(sockfd, F_GETFL, 0);
- if(FALSE != nonblock)
+ if(nonblock)
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
else
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
#elif defined(HAVE_IOCTL_FIONBIO)
/* older unix versions */
- int flags;
- flags = nonblock;
+ int flags = nonblock ? 1 : 0;
return ioctl(sockfd, FIONBIO, &flags);
#elif defined(HAVE_IOCTLSOCKET_FIONBIO)
/* Windows */
- unsigned long flags;
- flags = nonblock;
+ unsigned long flags = nonblock ? 1UL : 0UL;
return ioctlsocket(sockfd, FIONBIO, &flags);
#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)
/* Amiga */
- return IoctlSocket(sockfd, FIONBIO, (long)nonblock);
+ long flags = nonblock ? 1L : 0L;
+ return IoctlSocket(sockfd, FIONBIO, flags);
#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK)
/* BeOS */
- long b = nonblock ? 1 : 0;
+ long b = nonblock ? 1L : 0L;
return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
#else
View
@@ -570,7 +570,7 @@ static CURLcode pop3_multi_statemach(struct connectdata *conn, bool *done)
struct pop3_conn *pop3c = &conn->proto.pop3c;
CURLcode result = Curl_pp_multi_statemach(&pop3c->pp);
- *done = (bool)(pop3c->state == POP3_STOP);
+ *done = (pop3c->state == POP3_STOP) ? TRUE : FALSE;
return result;
}
View
@@ -73,7 +73,7 @@ static size_t convert_lineends(struct SessionHandle *data,
return(size);
}
- if(data->state.prev_block_had_trailing_cr == TRUE) {
+ if(data->state.prev_block_had_trailing_cr) {
/* The previous block of incoming data
had a trailing CR, which was turned into a LF. */
if(*startPtr == '\n') {
@@ -536,8 +536,8 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
ssize_t nread = 0;
size_t bytesfromsocket = 0;
char *buffertofill = NULL;
- bool pipelining = (bool)(conn->data->multi &&
- Curl_multi_canPipeline(conn->data->multi));
+ bool pipelining = (conn->data->multi &&
+ Curl_multi_canPipeline(conn->data->multi)) ? TRUE : FALSE;
/* Set 'num' to 0 or 1, depending on which socket that has been sent here.
If it is the second socket, we set num to 1. Otherwise to 0. This lets
View
@@ -1032,7 +1032,7 @@ static CURLcode smtp_multi_statemach(struct connectdata *conn,
else
result = Curl_pp_multi_statemach(&smtpc->pp);
- *done = (bool)(smtpc->state == SMTP_STOP);
+ *done = (smtpc->state == SMTP_STOP) ? TRUE : FALSE;
return result;
}
View
@@ -368,7 +368,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
curl_socket_t sock = conn->sock[sockindex];
struct SessionHandle *data = conn->data;
long timeout;
- bool socks5_resolve_local = (bool)(conn->proxytype == CURLPROXY_SOCKS5);
+ bool socks5_resolve_local = (conn->proxytype == CURLPROXY_SOCKS5)?TRUE:FALSE;
const size_t hostname_len = strlen(hostname);
ssize_t packetsize = 0;
View
@@ -2500,7 +2500,7 @@ static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done)
implementation */
result = ssh_statemach_act(conn, &block);
- *done = (bool)(sshc->state == SSH_STOP);
+ *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
ssh_block2waitfor(conn, block);
return result;
View
@@ -69,10 +69,10 @@ static bool safe_strequal(char* str1, char* str2)
{
if(str1 && str2)
/* both pointers point to something then compare them */
- return (bool)(0 != Curl_raw_equal(str1, str2));
+ return (0 != Curl_raw_equal(str1, str2)) ? TRUE : FALSE;
else
/* if both pointers are NULL then treat them as equal */
- return (bool)(!str1 && !str2);
+ return (!str1 && !str2) ? TRUE : FALSE;
}
bool
@@ -210,7 +210,7 @@ Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
/* mark this is being ssl requested from here on. */
conn->ssl[sockindex].use = TRUE;
res = curlssl_connect_nonblocking(conn, sockindex, done);
- if(!res && *done == TRUE)
+ if(!res && *done)
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
return res;
#else
View
@@ -166,14 +166,14 @@ static int passwd_callback(char *buf, int num, int verify
#define seed_enough(x) rand_enough()
static bool rand_enough(void)
{
- return (bool)(0 != RAND_status());
+ return (0 != RAND_status()) ? TRUE : FALSE;
}
#else
#define seed_enough(x) rand_enough(x)
static bool rand_enough(int nread)
{
/* this is a very silly decision to make */
- return (bool)(nread > 500);
+ return (nread > 500) ? TRUE : FALSE;
}
#endif
@@ -2564,7 +2564,7 @@ bool Curl_ossl_data_pending(const struct connectdata *conn,
{
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;
}
Oops, something went wrong.

0 comments on commit a502107

Please sign in to comment.