Menu

#853 Mixing bool with int in several places

closed-fixed
5
2013-06-21
2009-08-10
No

In a few places in the curl library sources, bool types are mixed with integer types, which causes warnings with the compiler I am using (SNC for PSP). These are easy to fix, the changes are below.

Thanks,
Benbuck Nason

==== curl/lib/ftp.c#2 (text) ====

@@ -3537,7 +3537,7 @@

/* But only if a body transfer was requested. */
if(ftp->transfer == FTPTRANSFER_BODY) {
- result = ftp_nb_type(conn, 1, FTP_LIST_TYPE);
+ result = ftp_nb_type(conn, TRUE, FTP_LIST_TYPE);
if(result)
return result;
}
@@ -4101,7 +4101,7 @@
bool *dophase_done)
{
CURLcode result=CURLE_OK;
- bool connected=0;
+ bool connected=FALSE;
struct SessionHandle *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
data->req.size = -1; /* make sure this is unknown at this point */

==== curl/lib/transfer.c#2 (text) ====

@@ -130,7 +130,9 @@
struct SessionHandle *data = conn->data;
size_t buffersize = (size_t)bytes;
int nread;
+#ifdef CURL_DOES_CONVERSIONS
bool sending_http_headers = FALSE;
+#endif

if(data->req.upload_chunky) {
/* if chunked Transfer-Encoding */
@@ -139,9 +141,11 @@
}
if((conn->protocol&PROT_HTTP) &&
(data->state.proto.http->sending == HTTPSEND_REQUEST)) {
+#ifdef CURL_DOES_CONVERSIONS
/* We're sending the HTTP request headers, not the data.
Remember that so we don't re-translate them into garbage. */
sending_http_headers = TRUE;
+#endif
}

/* this function returns a size_t, so we typecast to int to prevent warnings

==== curl/lib/url.c#2 (text) ====

@@ -3819,7 +3819,7 @@
if(data->set.use_netrc != CURL_NETRC_REQUIRED) {
/* We could use the one in the URL */

- conn->bits.user_passwd = 1; /* enable user+password */
+ conn->bits.user_passwd = TRUE; /* enable user+password */

if(*userpass != ':') {
/* the name is given, get user+password */
@@ -3984,7 +3984,7 @@
different host or similar. */
conn->bits.netrc = TRUE;

- conn->bits.user_passwd = 1; /* enable user+password */
+ conn->bits.user_passwd = TRUE; /* enable user+password */
}
}
}

Discussion

  • Benbuck Nason

    Benbuck Nason - 2009-08-10

    After posting this I realized I included some changes to transfer.c that are due to a different problem (variable sending_http_headers set but not used).

    -Ben

     
  • Daniel Stenberg

    Daniel Stenberg - 2009-08-11

    Thanks , these do indeed seem like accurate mistakes that should be fixed. I'll apply your fixes as soon as I get the chance!

     
  • Daniel Stenberg

    Daniel Stenberg - 2009-08-11
    • status: open --> open-accepted
     
  • Daniel Stenberg

    Daniel Stenberg - 2009-08-11
    • status: open-accepted --> closed-fixed
     
  • Daniel Stenberg

    Daniel Stenberg - 2009-08-11

    Thanks, the bool fixes have now been committed to CVS.

    The CURL_DOES_CONVERSIONS change had already been addressed in CVS.