From: Uwe Hermann Date: Sat, 1 Sep 2018 19:02:35 +0000 (+0200) Subject: ipdbg-la: Fix two compiler warnings on Windows. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9be587a14833129c5f9bb0f7acdbcbc8ce0d11b8;p=libsigrok.git ipdbg-la: Fix two compiler warnings on Windows. This is happening because the send() and recv() functions have different prototypes on POSIX and Windows. Using the casts is required on Windows and doesn't hurt on POSIX systems. [...]/protocol.c: In function 'tcp_send': [...]/protocol.c:161:26: warning: pointer targets in passing argument 2 of 'send' differ in signedness [-Wpointer-sign] out = send(tcp->socket, buf, len, 0); ^ In file included from [...]/protocol.c:24:0: [...]/include/winsock2.h:997:34: note: expected 'const char *' but argument is of type 'const uint8_t * {aka const unsigned char *}' WINSOCK_API_LINKAGE int WSAAPI send(SOCKET s,const char *buf,int len,int flags); ^ [...]/protocol.c: In function 'ipdbg_la_tcp_receive': [...]/protocol.c:201:32: warning: pointer targets in passing argument 2 of 'recv' differ in signedness [-Wpointer-sign] int len = recv(tcp->socket, buf, 1, 0); ^ In file included from [...]/protocol.c:24:0: [...]/include/winsock2.h:992:34: note: expected 'char *' but argument is of type 'uint8_t * {aka unsigned char *}' WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags); ^ --- diff --git a/src/hardware/ipdbg-la/protocol.c b/src/hardware/ipdbg-la/protocol.c index 367483fa..963a83ea 100644 --- a/src/hardware/ipdbg-la/protocol.c +++ b/src/hardware/ipdbg-la/protocol.c @@ -160,7 +160,7 @@ SR_PRIV int ipdbg_la_tcp_close(struct ipdbg_la_tcp *tcp) static int tcp_send(struct ipdbg_la_tcp *tcp, const uint8_t *buf, size_t len) { int out; - out = send(tcp->socket, buf, len, 0); + out = send(tcp->socket, (const char *)buf, len, 0); if (out < 0) { sr_err("Send error: %s", g_strerror(errno)); @@ -200,7 +200,7 @@ SR_PRIV int ipdbg_la_tcp_receive(struct ipdbg_la_tcp *tcp, if (data_available(tcp)) { while (received < 1) { - int len = recv(tcp->socket, buf, 1, 0); + int len = recv(tcp->socket, (char *)buf, 1, 0); if (len < 0) { sr_err("Receive error: %s", g_strerror(errno));