[Spice-devel,spice-gtk,Win32,v5,03/22] controller/test.c: mingw: fix compiler bad param warning for ReadFile

Submitted by Uri Lublin on July 9, 2012, 12:14 p.m.

Details

Message ID 9513b9c40f2e515de4a15c0ce31308750e85c35b.1341834461.git.uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin July 9, 2012, 12:14 p.m.
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(-)

Patch hide | download patch | download mbox

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)) {

Comments

ack

On Mon, Jul 9, 2012 at 2:14 PM, Uri Lublin <uril@redhat.com> wrote:
> 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.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel