From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123197 invoked by alias); 2 Nov 2015 20:40:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 123180 invoked by uid 89); 2 Nov 2015 20:40:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg20.ericsson.net Received: from usevmg20.ericsson.net (HELO usevmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 02 Nov 2015 20:40:19 +0000 Received: from EUSAAHC006.ericsson.se (Unknown_Domain [147.117.188.90]) by usevmg20.ericsson.net (Symantec Mail Security) with SMTP id 26.AD.32596.6F867365; Mon, 2 Nov 2015 14:45:26 +0100 (CET) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.92) with Microsoft SMTP Server id 14.3.248.2; Mon, 2 Nov 2015 15:40:16 -0500 Subject: Re: [PATCH 06/11] [C++/mingw] ser-tcp.c casts To: Pedro Alves , References: <1446492970-21432-1-git-send-email-palves@redhat.com> <1446492970-21432-7-git-send-email-palves@redhat.com> From: Simon Marchi Message-ID: <5637CA30.4080200@ericsson.com> Date: Mon, 02 Nov 2015 20:40:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1446492970-21432-7-git-send-email-palves@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00047.txt.bz2 On 15-11-02 02:36 PM, Pedro Alves wrote: > 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 You could have done exactly the opposite of the old comment, that is cast to (char *). It shouldn't generate any warning in either case. But I think that your way is fine too.