]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid -Wconversion error in dump_read_all under MS-Windows
authorDaniel Colascione <dancol@dancol.org>
Mon, 19 Feb 2018 16:55:37 +0000 (08:55 -0800)
committerDaniel Colascione <dancol@dancol.org>
Mon, 19 Feb 2018 17:01:41 +0000 (09:01 -0800)
src/pdumper.c

index efccafb07b76d74ba8145f52c5c2c57dcd4d9374..f66f3fedb9a54594102753a41ff0f47c4c3764a8 100644 (file)
@@ -4884,8 +4884,12 @@ dump_read_all (int fd, void *buf, size_t bytes_to_read)
   size_t bytes_read = 0;
   while (bytes_read < bytes_to_read)
     {
+      /* Some platforms accept only int-sized values to read.  */
+      unsigned chunk_to_read = UINT_MAX;
+      if (bytes_to_read - bytes_read < chunk_to_read)
+        chunk_to_read = (unsigned)(bytes_to_read - bytes_read);
       ssize_t chunk =
-        read (fd, (char*) buf + bytes_read, bytes_to_read - bytes_read);
+        read (fd, (char*) buf + bytes_read, chunk_to_read);
       if (chunk < 0)
         return chunk;
       if (chunk == 0)