emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] pdumper b7da1a5 6/6: Avoid -Wconversion error in dump_read


From: Daniel Colascione
Subject: [Emacs-diffs] pdumper b7da1a5 6/6: Avoid -Wconversion error in dump_read_all under MS-Windows
Date: Mon, 19 Feb 2018 12:02:50 -0500 (EST)

branch: pdumper
commit b7da1a5af8f189705ca596bcec6597a59b1aff9b
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    Avoid -Wconversion error in dump_read_all under MS-Windows
---
 src/pdumper.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/pdumper.c b/src/pdumper.c
index efccafb..f66f3fe 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]