[Spice-devel] [spice-gtk Win32 v4 17/17] controller/test.c: mingw: fix compiler bad param warning for ReadFile

Uri Lublin uril at redhat.com
Thu Jul 5 13:44:09 PDT 2012


It seems that ssize_t is int, while DWORD is long

Compiler warning (some whitespaces where added for readability):
  ../../../gtk/controller/test.c: In function 'read_from_pipe':
  ../../../gtk/controller/test.c:108:5: warning: passing argument 4 \
       of 'ReadFile' from incompatible pointer type [enabled by default]
  In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:70:0,
                   from ../../../gtk/controller/test.c:27:
  /usr/i686-w64-mingw32/sys-root/mingw/include/winbase.h:1426:29: note: expected \
       'LPDWORD' but argument is of type 'ssize_t *'
---
 gtk/controller/test.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/gtk/controller/test.c b/gtk/controller/test.c
index 3f3eb55..f6f3975 100644
--- a/gtk/controller/test.c
+++ b/gtk/controller/test.c
@@ -105,9 +105,11 @@ ssize_t read_from_pipe (void* data, size_t size)
 {
     ssize_t read;
 #ifdef WIN32
-    if (!ReadFile (pipe, data, size, &read, NULL)) {
+    DWORD bytes;
+    if (!ReadFile (pipe, data, size, &bytes, NULL)) {
         printf ("Read from pipe failed %u\n", GetLastError());
     }
+    read = bytes;
 #else
     read = recv (sock, data, size, 0);
     if ((read == -1 || read == 0)) {
-- 
1.7.7.6



More information about the Spice-devel mailing list