On Wednesday 23 February 2011 16:35:03 Stefan Krause wrote:
> in transfer.c, line 553 the following compiler warning is generated when
> compiling with VC 2005:
>
>
> \transfer.c(553) : warning C4244: 'function' : conversion from 'time_t' to
> 'long', possible loss of data
>
>    if(!Curl_meets_timecondition(data, k->timeofdoc)) {
>
>
> In 7.21.3 that warning hasn't been present. It seems to be introduced by
> the rewritten part of the source around these line.

Thank you for the report.  Does the attached patch solve the problem?

Kamil
From 3c95a42c93333f157c3da6a45efe3e03c95dec59 Mon Sep 17 00:00:00 2001
From: Stefan Krause <[email protected]>
Date: Wed, 23 Feb 2011 19:58:43 +0100
Subject: [PATCH] transfer: avoid insane conversion of time_t

---
 lib/file.c     |    2 +-
 lib/transfer.c |    2 +-
 lib/transfer.h |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/file.c b/lib/file.c
index a627a81..d4e941f 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -464,7 +464,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
   }
 
   if(fstated && !data->state.range && data->set.timecondition) {
-    if(!Curl_meets_timecondition(data, data->info.filetime)) {
+    if(!Curl_meets_timecondition(data, (time_t)data->info.filetime)) {
       *done = TRUE;
       return CURLE_OK;
     }
diff --git a/lib/transfer.c b/lib/transfer.c
index f316000..b3e6e99 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -359,7 +359,7 @@ static void read_rewind(struct connectdata *conn,
  * Check to see if CURLOPT_TIMECONDITION was met by comparing the time of the
  * remote document with the time provided by CURLOPT_TIMEVAL
  */
-bool Curl_meets_timecondition(struct SessionHandle *data, long timeofdoc)
+bool Curl_meets_timecondition(struct SessionHandle *data, time_t timeofdoc)
 {
   if((timeofdoc == 0) || (data->set.timevalue == 0))
     return TRUE;
diff --git a/lib/transfer.h b/lib/transfer.h
index c966caf..f60937c 100644
--- a/lib/transfer.h
+++ b/lib/transfer.h
@@ -47,7 +47,7 @@ CURLcode Curl_readrewind(struct connectdata *conn);
 CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp);
 CURLcode Curl_reconnect_request(struct connectdata **connp);
 CURLcode Curl_retry_request(struct connectdata *conn, char **url);
-bool Curl_meets_timecondition(struct SessionHandle *data, long timeofdoc);
+bool Curl_meets_timecondition(struct SessionHandle *data, time_t timeofdoc);
 
 /* This sets up a forthcoming transfer */
 void
-- 
1.7.4

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to