]> granicus.if.org Git - curl/commitdiff
anyauthput: fix compiler warning on 64-bit Windows
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Mon, 10 Sep 2018 19:10:38 +0000 (21:10 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Wed, 12 Sep 2018 10:25:53 +0000 (12:25 +0200)
On Windows, the read function from <io.h> is used, which has its byte
count parameter as unsigned int instead of size_t.

Closes https://github.com/curl/curl/pull/2972

docs/examples/anyauthput.c

index eb91d991b5675954479cb163f0b9aeaeeee813f3..14da10c3b228ccf4a61654f6b9e9d1c265c48eb8 100644 (file)
  */
 #include <stdio.h>
 #include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <curl/curl.h>
+
 #ifdef WIN32
 #  include <io.h>
+#  define READ_3RD_ARG unsigned int
 #else
 #  include <unistd.h>
+#  define READ_3RD_ARG size_t
 #endif
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <curl/curl.h>
 
 #if LIBCURL_VERSION_NUM < 0x070c03
 #error "upgrade your libcurl to no less than 7.12.3"
@@ -83,7 +86,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
   int *fdp = (int *)stream;
   int fd = *fdp;
 
-  retcode = read(fd, ptr, size * nmemb);
+  retcode = read(fd, ptr, (READ_3RD_ARG)(size * nmemb));
 
   nread = (curl_off_t)retcode;