net/socket: Fix compiler warning (regression for MinGW)
Subsystems (2)
PATCH 1/1 net/socket: Fix compiler warning (regression for MinGW)
Add a type cast which was removed by commit213fd5087e2e4e2da10ad266df0ba950cf7618bf 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 *’
--- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/socket.c +1 -1
@@ -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 );
Signature · 1 line
1.7.10
Quoted 9 lines · Stefan Weil
Add a type cast which was removed by commit
213fd5087e2e4e2da10ad266df0ba950cf7618bfagain.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 ‘constuint8_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
Quoted 11 lines · Stefan Hajnoczi
Quoted 9 lines · Stefan Weil
Add a type cast which was removed by commit
213fd5087e2e4e2da10ad266df0ba950cf7618bfagain.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 ‘constuint8_t*’
Quoted 6 lines
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:
Quoted 17 lines · Stefan Hajnoczi
Quoted 10 lines · Stefan Weil
Quoted 9 lines
Add a type cast which was removed by commit
213fd5087e2e4e2da10ad266df0ba950cf7618bfagain.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 ‘constuint8_t*’Quoted 6 lines
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().
Quoted 6 lines
There's
qemu_recv()inqemu-common.h, for exactly the same purpose. Butqemu_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.
Quoted 33 lines · Stefan Weil
Am 22.09.2012 20:01, schrieb Michael Tokarev:
Quoted 23 lines · Stefan Hajnoczi
Quoted 15 lines · Stefan Weil
Quoted 4 lines
Add a type cast which was removed by commit
213fd5087e2e4e2da10ad266df0ba950cf7618bfagain.Quoted 8 lines
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 ‘constuint8_t*’Quoted 6 lines
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().Quoted 6 lines
There's
qemu_recv()inqemu-common.h, for exactly the same purpose. Butqemu_recv()is much more evil, IMHO.Thanks,
/mjt
Quoted 6 lines
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_sendtotoqemu-common.h. Is there anybody who would prefer that solution?
Yes.
Quoted 4 lines
Regards
Stefan W.