From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDEM9-0001Mt-1N for qemu-devel@nongnu.org; Wed, 06 Mar 2013 08:26:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDEM2-0000Gq-PJ for qemu-devel@nongnu.org; Wed, 06 Mar 2013 08:26:04 -0500 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:33114) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDEM2-0000GR-8X for qemu-devel@nongnu.org; Wed, 06 Mar 2013 08:25:58 -0500 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Mar 2013 23:18:07 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 77196357802D for ; Thu, 7 Mar 2013 00:25:52 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r26DPm8n7864720 for ; Thu, 7 Mar 2013 00:25:49 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r26DPoqQ002098 for ; Thu, 7 Mar 2013 00:25:51 +1100 Message-ID: <513743D8.3000001@linux.vnet.ibm.com> Date: Wed, 06 Mar 2013 21:25:44 +0800 From: Lei Li MIME-Version: 1.0 References: <1362477081-31843-1-git-send-email-lilei@linux.vnet.ibm.com> <20130306095625.GB1954@stefanha-thinkpad.muc.redhat.com> <51373F8D.90909@linux.vnet.ibm.com> <20130306131637.GA11099@stefanha-thinkpad.muc.redhat.com> In-Reply-To: <20130306131637.GA11099@stefanha-thinkpad.muc.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] osdep: pass const char pointer to setsockopt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: mdroh@linux.vnet.ibm.com, qemu-devel@nongnu.org, Markus Armbruster On 03/06/2013 09:16 PM, Stefan Hajnoczi wrote: > On Wed, Mar 06, 2013 at 09:07:25PM +0800, Lei Li wrote: >> On 03/06/2013 05:56 PM, Stefan Hajnoczi wrote: >>> On Tue, Mar 05, 2013 at 05:51:21PM +0800, Lei Li wrote: >>>> Pass the right type for setsockopt(), and this will also >>>> fix the compiler warning when cross build for qemu-ga.exe: >>>> >>>> util/osdep.c: In function 'socket_set_nodelay': >>>> util/osdep.c:69:5: warning: passing argument 4 of 'setsockopt' from >>>> incompatible pointer type [enabled by default] >>>> In file included from /home/lei/qemu_b/include/sysemu/os-win32.h:30:0, >>>> from /home/lei/qemu_b/include/qemu-common.h:46, >>>> from util/osdep.c:48: >>>> /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:990:63: note: >>>> expected 'const char *' but argument is of type 'int *' >>>> >>>> Signed-off-by: Lei Li >>>> --- >>>> util/osdep.c | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/util/osdep.c b/util/osdep.c >>>> index c408261..ce472a9 100644 >>>> --- a/util/osdep.c >>>> +++ b/util/osdep.c >>>> @@ -57,7 +57,7 @@ static const char *qemu_version = QEMU_VERSION; >>>> int socket_set_cork(int fd, int v) >>>> { >>>> #if defined(SOL_TCP) && defined(TCP_CORK) >>>> - return setsockopt(fd, SOL_TCP, TCP_CORK, &v, sizeof(v)); >>>> + return setsockopt(fd, SOL_TCP, TCP_CORK, (char *)&v, sizeof(v)); >>>> #else >>>> return 0; >>>> #endif >>>> @@ -66,7 +66,7 @@ int socket_set_cork(int fd, int v) >>>> int socket_set_nodelay(int fd) >>>> { >>>> int v = 1; >>>> - return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v)); >>>> + return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&v, sizeof(v)); >>> Please use qemu_setsockopt() instead of open-coding this. >>> >>> Stefan >>> >> Hi Stefan, >> >> This compiler warning just shows up without any hacking >> when cross build qemu-ga for windows by: >> >> ./configure --enable-guest-agent --cross-prefix=i686-w64-mingw32- >> make qemu-ga.exe > I understand you didn't introduce the bug and noticed it when compiling > for Windows. > > The correct fix is still to use qemu_setsockopt() which was added in > order to solve this portability problem. > > You don't need any casts if you use qemu_setsockopt(). > > Stefan Sorry, I understand it just now... :-[ Sure, thanks! -- Lei