Message ID | 1348169539-24797-1-git-send-email-sw@weilnetz.de |
---|---|
State | Superseded |
Headers | show |
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
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
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.
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. >
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);
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(-)