From 6b1220b61d5ed2481dbf31714a68be6ef6eed3da Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 26 Apr 2005 13:08:49 +0000 Subject: [PATCH] Cory Nelson's work on nuking compiler warnings when building on x64 with VS2005. --- lib/connect.c | 2 +- lib/cookie.c | 4 ++-- lib/formdata.c | 4 ++-- lib/ftp.c | 8 ++++---- lib/hostthre.c | 2 +- lib/inet_pton.c | 2 +- lib/md5.c | 2 +- lib/mprintf.c | 8 ++++---- lib/parsedate.c | 2 +- lib/select.c | 4 ++-- lib/strerror.c | 2 +- lib/transfer.c | 26 +++++++++++++------------- lib/url.c | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/connect.c b/lib/connect.c index f402ede77..c7b3c51bb 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -652,7 +652,7 @@ singleipconnect(struct connectdata *conn, /* set socket non-blocking */ Curl_nonblock(sockfd, TRUE); - rc = connect(sockfd, ai->ai_addr, ai->ai_addrlen); + rc = connect(sockfd, ai->ai_addr, (socklen_t)ai->ai_addrlen); if(-1 == rc) { error = Curl_ourerrno(); diff --git a/lib/cookie.c b/lib/cookie.c index e608f72e1..019c00b71 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -309,7 +309,7 @@ Curl_cookie_add(struct SessionHandle *data, break; } co->expires = - atoi((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0]) + now; + atoi((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0]) + (long)now; } else if(strequal("expires", name)) { co->expirestr=strdup(whatptr); @@ -317,7 +317,7 @@ Curl_cookie_add(struct SessionHandle *data, badcookie = TRUE; break; } - co->expires = curl_getdate(what, &now); + co->expires = (long)curl_getdate(what, &now); } else if(!co->name) { co->name = strdup(name); diff --git a/lib/formdata.c b/lib/formdata.c index 1d11bc939..8fe1556ba 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -464,7 +464,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, return_value = CURL_FORMADD_OPTION_TWICE; else current_form->namelength = - array_state?(long)array_value:va_arg(params, long); + array_state?(long)array_value:(long)va_arg(params, long); break; /* @@ -1550,7 +1550,7 @@ char *Curl_FormBoundary(void) if(!retstring) return NULL; /* failed */ - srand(time(NULL)+randomizer++); /* seed */ + srand((unsigned int)time(NULL)+randomizer++); /* seed */ strcpy(retstring, "----------------------------"); diff --git a/lib/ftp.c b/lib/ftp.c index 65d4d3693..a01c3d8e7 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -266,8 +266,8 @@ static CURLcode ftp_readresp(curl_socket_t sockfd, ptr=buf + ftp->nread_resp; - perline= ptr-ftp->linestart_resp; /* number of bytes in the current line, - so far */ + perline= (int)(ptr-ftp->linestart_resp); /* number of bytes in the current + line, so far */ keepon=TRUE; while((ftp->nread_respinfo.filetime = curl_getdate(buf, &secs); + data->info.filetime = (long)curl_getdate(buf, &secs); } /* If we asked for a time of the file and we actually got one as well, @@ -2086,7 +2086,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn, char *bytes; bytes=strstr(buf, " bytes"); if(bytes--) { - long in=bytes-buf; + long in=(long)(bytes-buf); /* this is a hint there is size information in there! ;-) */ while(--in) { /* scan for the left parenthesis and break there */ diff --git a/lib/hostthre.c b/lib/hostthre.c index dd3f896c9..eb663e88b 100644 --- a/lib/hostthre.c +++ b/lib/hostthre.c @@ -548,7 +548,7 @@ CURLcode Curl_resolv_fdset(struct connectdata *conn, if (td && td->dummy_sock != CURL_SOCKET_BAD) { FD_SET(td->dummy_sock,write_fd_set); - *max_fdp = td->dummy_sock; + *max_fdp = (int)td->dummy_sock; } (void) read_fd_set; return CURLE_OK; diff --git a/lib/inet_pton.c b/lib/inet_pton.c index e8d4636b3..35eef49d0 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -114,7 +114,7 @@ inet_pton4(const char *src, unsigned char *dst) const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - u_int val = *tp * 10 + (pch - digits); + u_int val = *tp * 10 + (u_int)(pch - digits); if (val > 255) return (0); diff --git a/lib/md5.c b/lib/md5.c index 7e9c3e9eb..274ebe897 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -345,7 +345,7 @@ void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */ { MD5_CTX ctx; MD5_Init(&ctx); - MD5_Update(&ctx, input, strlen((char *)input)); + MD5_Update(&ctx, input, (unsigned int)strlen((char *)input)); MD5_Final(outbuffer, &ctx); } diff --git a/lib/mprintf.c b/lib/mprintf.c index 30f0f7aa5..b9fe238f9 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -759,8 +759,8 @@ static int dprintf_formatf( *w-- = digits[num % base]; num /= base; } - width -= workend - w; - prec -= workend - w; + width -= (long)(workend - w); + prec -= (long)(workend - w); if (alt && base == 8 && prec <= 0) { *w-- = '0'; @@ -839,7 +839,7 @@ static int dprintf_formatf( if (prec != -1 && (size_t) prec < len) len = prec; - width -= len; + width -= (long)len; if (p->flags & FLAGS_ALT) OUTCHAR('"'); @@ -869,7 +869,7 @@ static int dprintf_formatf( base = 16; digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits; alt = 1; - num = (unsigned long) ptr; + num = (size_t) ptr; is_neg = 0; goto number; } diff --git a/lib/parsedate.c b/lib/parsedate.c index 26f573fdd..52529848d 100644 --- a/lib/parsedate.c +++ b/lib/parsedate.c @@ -398,7 +398,7 @@ static time_t Curl_parsedate(const char *date) /* Add the time zone diff (between the given timezone and GMT) and the diff between the local time zone and GMT. */ - delta = (tzoff!=-1?tzoff:0) + (t - t2); + delta = (long)((tzoff!=-1?tzoff:0) + (t - t2)); if((delta>0) && (t + delta < t)) return -1; /* time_t overflow */ diff --git a/lib/select.c b/lib/select.c index 59aec52bd..634f8efda 100644 --- a/lib/select.c +++ b/lib/select.c @@ -151,7 +151,7 @@ int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms) } do { - r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout); + r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout); } while((r == -1) && (Curl_ourerrno() == EINTR)); if (r < 0) @@ -236,7 +236,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms) } do { - r = select(maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout); + r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout); } while((r == -1) && (Curl_ourerrno() == EINTR)); if (r < 0) diff --git a/lib/strerror.c b/lib/strerror.c index b567f9bee..dcc7f5040 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -571,7 +571,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) else { if (!get_winsock_error(err, buf, max) && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, - LANG_NEUTRAL, buf, max, NULL)) + LANG_NEUTRAL, buf, (DWORD)max, NULL)) snprintf(buf, max, "Unknown error %d (%#x)", err, err); } #endif diff --git a/lib/transfer.c b/lib/transfer.c index aa4e385d1..bb93950cd 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -270,9 +270,9 @@ CURLcode Curl_readwrite(struct connectdata *conn, ssize_t nread; /* number of bytes read */ int didwhat=0; - int fd_read; - int fd_write; - int select_res; + curl_socket_t fd_read; + curl_socket_t fd_write; + curl_socket_t select_res; curl_off_t contentlength; @@ -395,7 +395,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* decrease the size of the remaining (supposed) header line */ rest_length = (k->end_ptr - k->str)+1; - nread -= rest_length; + nread -= (ssize_t)rest_length; k->str = k->end_ptr + 1; /* move past new line */ @@ -520,8 +520,8 @@ CURLcode Curl_readwrite(struct connectdata *conn, if(result) return result; - data->info.header_size += headerlen; - conn->headerbytecount += headerlen; + data->info.header_size += (long)headerlen; + conn->headerbytecount += (long)headerlen; conn->deductheadercount = (100 == k->httpcode)?conn->headerbytecount:0; @@ -900,7 +900,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"), &secs); if(data->set.get_filetime) - data->info.filetime = k->timeofdoc; + data->info.filetime = (long)k->timeofdoc; } else if((checkprefix("WWW-Authenticate:", k->p) && (401 == k->httpcode)) || @@ -963,8 +963,8 @@ CURLcode Curl_readwrite(struct connectdata *conn, if(result) return result; - data->info.header_size += k->hbuflen; - conn->headerbytecount += k->hbuflen; + data->info.header_size += (long)k->hbuflen; + conn->headerbytecount += (long)k->hbuflen; /* reset hbufp pointer && hbuflen */ k->hbufp = data->state.headerbuff; @@ -1501,7 +1501,7 @@ void Curl_single_fdset(struct connectdata *conn, *max_fd = -1; /* init */ if(conn->keep.keepon & KEEP_READ) { FD_SET(conn->sockfd, read_fd_set); - *max_fd = conn->sockfd; + *max_fd = (int)conn->sockfd; } if(conn->keep.keepon & KEEP_WRITE) { FD_SET(conn->writesockfd, write_fd_set); @@ -1509,7 +1509,7 @@ void Curl_single_fdset(struct connectdata *conn, /* since sockets are curl_socket_t nowadays, we typecast it to int here to compare it nicely */ if((int)conn->writesockfd > *max_fd) - *max_fd = conn->writesockfd; + *max_fd = (int)conn->writesockfd; } /* we don't use exceptions, only touch that one to prevent compiler warnings! */ @@ -1553,8 +1553,8 @@ Transfer(struct connectdata *conn) return CURLE_OK; while (!done) { - int fd_read; - int fd_write; + curl_socket_t fd_read; + curl_socket_t fd_write; int interval_ms; interval_ms = 1 * 1000; diff --git a/lib/url.c b/lib/url.c index fb9c5905d..75e340064 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1748,7 +1748,7 @@ static int handleSock5Proxy(const char *proxy_name, ssize_t written; int result; CURLcode code; - int sock = conn->sock[FIRSTSOCKET]; + curl_socket_t sock = conn->sock[FIRSTSOCKET]; Curl_nonblock(sock, FALSE);