* [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW)
@ 2012-09-22 19:13 Stefan Weil
2012-09-23 6:37 ` Stefan Hajnoczi
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2012-09-22 19:13 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Blue Swirl, qemu-trivial, qemu-devel, Stefan Weil
Commit 213fd5087e2e4e2da10ad266df0ba950cf7618bf removed a type cast
which is needed for MinGW:
net/socket.c:136: warning:
pointer targets in passing argument 2 of ‘sendto’ differ in signedness
/usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:
expected ‘const char *’ but argument is of type ‘const uint8_t *’
Add a 'qemu_sendto' macro which provides that type cast where needed
and use the new macro instead of 'sendto'.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
I hope the modifications are trivial enough to justify that I did not
split this in two patches.
Regards
Stefan W.
net/socket.c | 6 +++---
qemu-common.h | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index 69aad03..ce4f980 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -131,9 +131,9 @@ static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf,
ssize_t ret;
do {
- ret = sendto(s->fd, buf, size, 0,
- (struct sockaddr *)&s->dgram_dst,
- sizeof(s->dgram_dst));
+ ret = qemu_sendto(s->fd, buf, size, 0,
+ (struct sockaddr *)&s->dgram_dst,
+ sizeof(s->dgram_dst));
} while (ret == -1 && errno == EINTR);
if (ret == -1 && errno == EAGAIN) {
diff --git a/qemu-common.h b/qemu-common.h
index 2f00c15..4f0ed9e 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -225,9 +225,14 @@ int qemu_pipe(int pipefd[2]);
#endif
#ifdef _WIN32
+/* MinGW needs a type cast for the 'buf' argument. */
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
+#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
+ sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
#else
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
+#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
+ sendto(sockfd, buf, len, flags, destaddr, addrlen)
#endif
/* Error handling. */
--
1.7.10
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW)
2012-09-22 19:13 [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW) Stefan Weil
@ 2012-09-23 6:37 ` Stefan Hajnoczi
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2012-09-23 6:37 UTC (permalink / raw)
To: Stefan Weil; +Cc: Blue Swirl, qemu-trivial, qemu-devel
On Sat, Sep 22, 2012 at 09:13:28PM +0200, Stefan Weil wrote:
> Commit 213fd5087e2e4e2da10ad266df0ba950cf7618bf removed a type cast
> which is needed for MinGW:
>
> net/socket.c:136: warning:
> pointer targets in passing argument 2 of ‘sendto’ differ in signedness
> /usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:
> expected ‘const char *’ but argument is of type ‘const uint8_t *’
>
> Add a 'qemu_sendto' macro which provides that type cast where needed
> and use the new macro instead of 'sendto'.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> I hope the modifications are trivial enough to justify that I did not
> split this in two patches.
>
> Regards
>
> Stefan W.
>
> net/socket.c | 6 +++---
> qemu-common.h | 5 +++++
> 2 files changed, 8 insertions(+), 3 deletions(-)
Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW)
@ 2012-09-20 19:32 Stefan Weil
2012-09-22 16:32 ` Stefan Hajnoczi
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2012-09-20 19:32 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-trivial, Stefan Weil, qemu-devel
Add a type cast which was removed by commit
213fd5087e2e4e2da10ad266df0ba950cf7618bf again.
Without it, MinGW compilers complain:
net/socket.c:136: warning:
pointer targets in passing argument 2 of ‘sendto’ differ in signedness
/usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:
expected ‘const char *’ but argument is of type ‘const uint8_t *’
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
net/socket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/socket.c b/net/socket.c
index 69aad03..833f79f 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -131,7 +131,7 @@ static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf,
ssize_t ret;
do {
- ret = sendto(s->fd, buf, size, 0,
+ ret = sendto(s->fd, (const void *)buf, size, 0,
(struct sockaddr *)&s->dgram_dst,
sizeof(s->dgram_dst));
} while (ret == -1 && errno == EINTR);
--
1.7.10
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW)
2012-09-20 19:32 Stefan Weil
@ 2012-09-22 16:32 ` Stefan Hajnoczi
2012-09-22 18:01 ` Michael Tokarev
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2012-09-22 16:32 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel
On Thu, Sep 20, 2012 at 09:32:19PM +0200, Stefan Weil wrote:
> Add a type cast which was removed by commit
> 213fd5087e2e4e2da10ad266df0ba950cf7618bf again.
>
> Without it, MinGW compilers complain:
>
> net/socket.c:136: warning:
> pointer targets in passing argument 2 of ‘sendto’ differ in signedness
> /usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:
> expected ‘const char *’ but argument is of type ‘const uint8_t *’
Wow, that's messed up. sendto() is POSIX and the prototype shouldn't be
const char *.
It's easy for someone to remove this cast in the future. Please add a
comment explaining that it's needed because MinGW headers don't have the
POSIX version of sendto().
Thanks,
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW)
2012-09-22 16:32 ` Stefan Hajnoczi
@ 2012-09-22 18:01 ` Michael Tokarev
2012-09-22 18:17 ` Stefan Weil
0 siblings, 1 reply; 7+ messages in thread
From: Michael Tokarev @ 2012-09-22 18:01 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-trivial, Stefan Weil, qemu-devel
On 22.09.2012 20:32, Stefan Hajnoczi wrote:
> On Thu, Sep 20, 2012 at 09:32:19PM +0200, Stefan Weil wrote:
>> Add a type cast which was removed by commit
>> 213fd5087e2e4e2da10ad266df0ba950cf7618bf again.
>>
>> Without it, MinGW compilers complain:
>>
>> net/socket.c:136: warning:
>> pointer targets in passing argument 2 of ‘sendto’ differ in signedness
>> /usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:
>> expected ‘const char *’ but argument is of type ‘const uint8_t *’
>
> Wow, that's messed up. sendto() is POSIX and the prototype shouldn't be
> const char *.
>
> It's easy for someone to remove this cast in the future. Please add a
> comment explaining that it's needed because MinGW headers don't have the
> POSIX version of sendto().
There's qemu_recv() in qemu-common.h, for exactly the same purpose.
But qemu_recv() is much more evil, IMHO.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW)
2012-09-22 18:01 ` Michael Tokarev
@ 2012-09-22 18:17 ` Stefan Weil
2012-09-22 18:25 ` Blue Swirl
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2012-09-22 18:17 UTC (permalink / raw)
To: Michael Tokarev; +Cc: Blue Swirl, Stefan Hajnoczi, qemu-trivial, qemu-devel
Am 22.09.2012 20:01, schrieb Michael Tokarev:
> On 22.09.2012 20:32, Stefan Hajnoczi wrote:
>> On Thu, Sep 20, 2012 at 09:32:19PM +0200, Stefan Weil wrote:
>>> Add a type cast which was removed by commit
>>> 213fd5087e2e4e2da10ad266df0ba950cf7618bf again.
>>>
>>> Without it, MinGW compilers complain:
>>>
>>> net/socket.c:136: warning:
>>> pointer targets in passing argument 2 of ‘sendto’ differ in signedness
>>> /usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:
>>> expected ‘const char *’ but argument is of type ‘const uint8_t *’
>> Wow, that's messed up. sendto() is POSIX and the prototype shouldn't be
>> const char *.
>>
>> It's easy for someone to remove this cast in the future. Please add a
>> comment explaining that it's needed because MinGW headers don't have the
>> POSIX version of sendto().
> There's qemu_recv() in qemu-common.h, for exactly the same purpose.
> But qemu_recv() is much more evil, IMHO.
>
> Thanks,
>
> /mjt
Thanks for the hint.
I already sent v2 of my patch (with a comment as suggested by Stefan H.).
Of course we could also add a qemu_sendto to qemu-common.h.
Is there anybody who would prefer that solution?
Regards
Stefan W.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW)
2012-09-22 18:17 ` Stefan Weil
@ 2012-09-22 18:25 ` Blue Swirl
0 siblings, 0 replies; 7+ messages in thread
From: Blue Swirl @ 2012-09-22 18:25 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, Stefan Hajnoczi, Michael Tokarev, qemu-devel
On Sat, Sep 22, 2012 at 6:17 PM, Stefan Weil <sw@weilnetz.de> wrote:
> Am 22.09.2012 20:01, schrieb Michael Tokarev:
>
>> On 22.09.2012 20:32, Stefan Hajnoczi wrote:
>>>
>>> On Thu, Sep 20, 2012 at 09:32:19PM +0200, Stefan Weil wrote:
>>>>
>>>> Add a type cast which was removed by commit
>>>> 213fd5087e2e4e2da10ad266df0ba950cf7618bf again.
>>>>
>>>> Without it, MinGW compilers complain:
>>>>
>>>> net/socket.c:136: warning:
>>>> pointer targets in passing argument 2 of ‘sendto’ differ in signedness
>>>>
>>>> /usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313:
>>>> note:
>>>> expected ‘const char *’ but argument is of type ‘const uint8_t *’
>>>
>>> Wow, that's messed up. sendto() is POSIX and the prototype shouldn't be
>>> const char *.
>>>
>>> It's easy for someone to remove this cast in the future. Please add a
>>> comment explaining that it's needed because MinGW headers don't have the
>>> POSIX version of sendto().
>>
>> There's qemu_recv() in qemu-common.h, for exactly the same purpose.
>> But qemu_recv() is much more evil, IMHO.
>>
>> Thanks,
>>
>> /mjt
>
>
> Thanks for the hint.
>
> I already sent v2 of my patch (with a comment as suggested by Stefan H.).
>
> Of course we could also add a qemu_sendto to qemu-common.h.
> Is there anybody who would prefer that solution?
Yes.
>
> Regards
> Stefan W.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-09-23 6:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-22 19:13 [Qemu-devel] [PATCH] net/socket: Fix compiler warning (regression for MinGW) Stefan Weil
2012-09-23 6:37 ` Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2012-09-20 19:32 Stefan Weil
2012-09-22 16:32 ` Stefan Hajnoczi
2012-09-22 18:01 ` Michael Tokarev
2012-09-22 18:17 ` Stefan Weil
2012-09-22 18:25 ` Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).