From patchwork Mon Nov 2 19:36:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 9504 Received: (qmail 20688 invoked by alias); 2 Nov 2015 19:36:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20595 invoked by uid 89); 2 Nov 2015 19:36:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 02 Nov 2015 19:36:19 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 34B19C0A524A for ; Mon, 2 Nov 2015 19:36:18 +0000 (UTC) Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA2JaAPx009459 for ; Mon, 2 Nov 2015 14:36:17 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 06/11] [C++/mingw] ser-tcp.c casts Date: Mon, 2 Nov 2015 19:36:05 +0000 Message-Id: <1446492970-21432-7-git-send-email-palves@redhat.com> In-Reply-To: <1446492970-21432-1-git-send-email-palves@redhat.com> References: <1446492970-21432-1-git-send-email-palves@redhat.com> Fixes a few errors like these: ../../src/gdb/ser-tcp.c: In function 'int net_open(serial*, const char*)': ../../src/gdb/ser-tcp.c:286:73: error: invalid conversion from 'void*' to 'char*' [-fpermissive] res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len); ^ gdb/ChangeLog: 2015-11-01 Pedro Alves * ser-tcp.c (net_open) [USE_WIN32API]: Cast getsockopt argument to char * instead of void *. (net_read_prim): Cast recv argument to char * instead of void *. (net_write_prim): Cast send argument to char * instead of void *. --- gdb/ser-tcp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c index ce40b61..507e0a1 100644 --- a/gdb/ser-tcp.c +++ b/gdb/ser-tcp.c @@ -280,10 +280,12 @@ net_open (struct serial *scb, const char *name) len = sizeof (err); /* On Windows, the fourth parameter to getsockopt is a "char *"; - on UNIX systems it is generally "void *". The cast to "void *" - is OK everywhere, since in C "void *" can be implicitly - converted to any pointer type. */ + on UNIX systems it is generally "void *". */ +#ifdef USE_WIN32API + res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (char *) &err, &len); +#else res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len); +#endif if (res < 0 || err) { /* Maybe the target still isn't ready to accept the connection. */ @@ -339,16 +341,21 @@ net_close (struct serial *scb) int net_read_prim (struct serial *scb, size_t count) { - /* Need to cast to silence -Wpointer-sign on MinGW, as Winsock's - 'recv' takes 'char *' as second argument, while 'scb->buf' is - 'unsigned char *'. */ +#ifdef USE_WIN32API + return recv (scb->fd, (char *) scb->buf, count, 0); +#else return recv (scb->fd, (void *) scb->buf, count, 0); +#endif } int net_write_prim (struct serial *scb, const void *buf, size_t count) { +#ifdef USE_WIN32API + return send (scb->fd, (const char *) buf, count, 0); +#else return send (scb->fd, buf, count, 0); +#endif } int