Patchwork [2/3] slirp: fix warning on mingw32

login
register
mail settings
Submitter Blue Swirl
Date July 23, 2011, 9:25 p.m.
Message ID <CAAu8pHtFhHT3M9c3SFzC2RF7GLuyN_4FX-f-Yo8qt+kU+BDCPQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/106496/
State New
Headers show

Comments

Blue Swirl - July 23, 2011, 9:25 p.m.
Avoid this warning:
  CC    slirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv'
from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32:
note: expected 'char *' but argument is of type 'struct icmp *'

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 slirp/ip_icmp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Anthony Liguori - July 23, 2011, 10:23 p.m.
On 07/23/2011 04:25 PM, Blue Swirl wrote:
> Avoid this warning:
>    CC    slirp/ip_icmp.o
> /src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
> /src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv'
> from incompatible pointer type [-Werror]
> /usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32:
> note: expected 'char *' but argument is of type 'struct icmp *'
>
> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
> ---
>   slirp/ip_icmp.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
> index 14a5312..a208648 100644
> --- a/slirp/ip_icmp.c
> +++ b/slirp/ip_icmp.c
> @@ -415,7 +415,7 @@ void icmp_receive(struct socket *so)
>       icp = mtod(m, struct icmp *);
>
>       id = icp->icmp_id;
> -    len = recv(so->s, icp, m->m_len, 0);
> +    len = recv(so->s, (char *)icp, m->m_len, 0);

(char *) is wrong.  recv() takes a void *.

Maybe we need to introduce a qemu_recv?

Regards,

Anthony Liguori

>       icp->icmp_id = id;
>
>       m->m_data -= hlen;
Stefan Weil - July 24, 2011, 6:20 a.m.
Am 24.07.2011 00:23, schrieb Anthony Liguori:
> On 07/23/2011 04:25 PM, Blue Swirl wrote:
>> Avoid this warning:
>>    CC    slirp/ip_icmp.o
>> /src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
>> /src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv'
>> from incompatible pointer type [-Werror]
>> /usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: 
>>
>> note: expected 'char *' but argument is of type 'struct icmp *'
>>
>> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
>> ---
>>   slirp/ip_icmp.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
>> index 14a5312..a208648 100644
>> --- a/slirp/ip_icmp.c
>> +++ b/slirp/ip_icmp.c
>> @@ -415,7 +415,7 @@ void icmp_receive(struct socket *so)
>>       icp = mtod(m, struct icmp *);
>>
>>       id = icp->icmp_id;
>> -    len = recv(so->s, icp, m->m_len, 0);
>> +    len = recv(so->s, (char *)icp, m->m_len, 0);
>
> (char *) is wrong.  recv() takes a void *.
>
> Maybe we need to introduce a qemu_recv?
>
> Regards,
>
> Anthony Liguori

Microsoft's recv() takes a char *.
Both (char *)icp and (void *)icp should work here for any host.

I suggest adding a comment:
/* Type cast needed for MinGW recv. */

Regards,

Stefan Weil

Patch

From 37628ecdfc668419a7724687249f2791e9241847 Mon Sep 17 00:00:00 2001
Message-Id: <37628ecdfc668419a7724687249f2791e9241847.1311456245.git.blauwirbel@gmail.com>
In-Reply-To: <8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32.1311456245.git.blauwirbel@gmail.com>
References: <8bcd08d1fe7c90869ea6659b6248ace6cf7b1f32.1311456245.git.blauwirbel@gmail.com>
From: Blue Swirl <blauwirbel@gmail.com>
Date: Sat, 23 Jul 2011 20:04:29 +0000
Subject: [PATCH 2/3] slirp: fix warning on mingw32

Avoid this warning:
  CC    slirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *'

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 slirp/ip_icmp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 14a5312..a208648 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -415,7 +415,7 @@  void icmp_receive(struct socket *so)
     icp = mtod(m, struct icmp *);
 
     id = icp->icmp_id;
-    len = recv(so->s, icp, m->m_len, 0);
+    len = recv(so->s, (char *)icp, m->m_len, 0);
     icp->icmp_id = id;
 
     m->m_data -= hlen;
-- 
1.7.2.5