]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Stefan Krause pointed out a compiler warning with a picky MSCV compiler when
authorDaniel Stenberg <daniel@haxx.se>
Tue, 5 Dec 2006 21:40:14 +0000 (21:40 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 5 Dec 2006 21:40:14 +0000 (21:40 +0000)
passing a curl_off_t argument to the Curl_read_rewind() function which takes
an size_t argument. Curl_read_rewind() also had debug code left in it and it
was put in a different source file with no good reason when only used from
one single spot.

CHANGES
RELEASE-NOTES
lib/sendf.c
lib/transfer.c

diff --git a/CHANGES b/CHANGES
index 9f7c952e3f4fec7121a8f4ae661453c45197d17c..60828fd3dd8613fa315e3c05fcbd8ec65bfa9bdf 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,12 @@
                                   Changelog
 
 Daniel (5 December 2006)
+- Stefan Krause pointed out a compiler warning with a picky MSCV compiler when
+  passing a curl_off_t argument to the Curl_read_rewind() function which takes
+  an size_t argument. Curl_read_rewind() also had debug code left in it and it
+  was put in a different source file with no good reason when only used from
+  one single spot.
+
 - Sh Diao reported that CURLOPT_CLOSEPOLICY doesn't work, and indeed, there is
   no code present in the library that receives the option. Since it was not
   possible to use, we know that no current users exist and thus we simply
index 9d8d554b1105b81cced801dfc2d09b9d5a914d00..2cb16a6200370a60cab7f9fce3c83591b28e8c39 100644 (file)
@@ -49,6 +49,7 @@ advice from friends like these:
 
  James Housley, Olaf Stueben, Yang Tse, Gisle Vanem, Bradford Bruce,
  Ciprian Badescu, Dmitriy Sergeyev, Nir Soffer, Venkat Akella, Toon Verwaest,
- Matt Witherspoon, Alexey Simak, Martin Skinner, Sh Diao, Jared Lundell
+ Matt Witherspoon, Alexey Simak, Martin Skinner, Sh Diao, Jared Lundell,
+ Stefan Krause
 
         Thanks! (and sorry if I forgot to mention someone)
index ddd8b9b5ca843edeac4efa9f2e70b99a13fa3348..7d203879f72688e99db48c1ee504782956f075c0 100644 (file)
@@ -455,24 +455,6 @@ CURLcode Curl_client_write(struct connectdata *conn,
 
 #define MIN(a,b) (a < b ? a : b)
 
-void Curl_read_rewind(struct connectdata *conn,
-                      size_t extraBytesRead)
-{
-    char buf[512 + 1];
-    size_t bytesToShow;
-
-    conn->read_pos -= extraBytesRead;
-    conn->bits.stream_was_rewound = TRUE;
-
-    bytesToShow = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
-    memcpy(buf, conn->master_buffer + conn->read_pos, bytesToShow);
-    buf[bytesToShow] = '\0';
-
-    DEBUGF(infof(conn->data,
-                 "Buffer after stream rewind (read_pos = %d): [%s]",
-                 conn->read_pos, buf));
-}
-
 /*
  * Internal read-from-socket function. This is meant to deal with plain
  * sockets, SSL sockets and kerberos sockets.
index a40c103e18585aac69b14820de054460ff283593..4406aeb4fde1154d91b1df5e86cc2199fa30f9c1 100644 (file)
@@ -266,6 +266,32 @@ static int data_pending(struct connectdata *conn)
 #define data_pending(x) 0
 #endif
 
+#ifndef MIN
+#define MIN(a,b) (a < b ? a : b)
+#endif
+
+static void read_rewind(struct connectdata *conn,
+                        size_t thismuch)
+{
+  conn->read_pos -= thismuch;
+  conn->bits.stream_was_rewound = TRUE;
+
+#ifdef CURLDEBUG
+  {
+    char buf[512 + 1];
+    size_t show;
+
+    show = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
+    memcpy(buf, conn->master_buffer + conn->read_pos, show);
+    buf[show] = '\0';
+
+    DEBUGF(infof(conn->data,
+                 "Buffer after stream rewind (read_pos = %d): [%s]",
+                 conn->read_pos, buf));
+  }
+#endif
+}
+
 /*
  * Curl_readwrite() is the low-level function to be called when data is to
  * be read and written to/from the connection.
@@ -1145,8 +1171,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
 
           if((-1 != k->maxdownload) &&
              (k->bytecount + nread >= k->maxdownload)) {
-            curl_off_t excess = k->bytecount +
-              ((curl_off_t) nread) - k->maxdownload;
+            /* The 'excess' amount below can't be more than BUFSIZE which
+               always will fit in a size_t */
+            size_t excess = k->bytecount + nread - k->maxdownload;
             if (excess > 0 && !k->ignorebody) {
               infof(data,
                     "Rewinding stream by : %" FORMAT_OFF_T
@@ -1155,7 +1182,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
                     ", bytecount = %" FORMAT_OFF_T ", nread = %d)\n",
                     excess, conn->data->reqdata.path,
                     k->size, k->maxdownload, k->bytecount, nread);
-              Curl_read_rewind(conn, excess);
+              read_rewind(conn, excess);
             }
 
             nread = (ssize_t) (k->maxdownload - k->bytecount);