From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTU5y-0003R1-K0 for qemu-devel@nongnu.org; Wed, 10 Feb 2016 07:42:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTU5u-00036I-Nz for qemu-devel@nongnu.org; Wed, 10 Feb 2016 07:42:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTU5u-00036C-Ic for qemu-devel@nongnu.org; Wed, 10 Feb 2016 07:42:06 -0500 References: <06d461a76323aec31c62db291e292da1c78107a5.1454927009.git.samuel.thibault@ens-lyon.org> <56BB1529.5080905@redhat.com> <20160210123014.GC6020@var.bordeaux.inria.fr> From: Thomas Huth Message-ID: <56BB3017.8030708@redhat.com> Date: Wed, 10 Feb 2016 13:41:59 +0100 MIME-Version: 1.0 In-Reply-To: <20160210123014.GC6020@var.bordeaux.inria.fr> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv7 7/9] slirp: Handle IPv6 in TCP functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Samuel Thibault Cc: zhanghailiang , Li Zhijian , Stefan Hajnoczi , Jason Wang , qemu-devel@nongnu.org, Vasiliy Tolstov , Dave Gilbert , Gonglei , Jan Kiszka , Huangpeng , Yang Hongyang , Guillaume Subiron On 10.02.2016 13:30, Samuel Thibault wrote: > Thomas Huth, on Wed 10 Feb 2016 11:47:05 +0100, wrote: >>> + ip = mtod(m, struct ip *); >>> + ip6 = mtod(m, struct ip6 *); >>> + save_ip = *ip; >>> + save_ip6 = *ip6; >> >> Could you do the "save_ip = *ip" within the "case AF_INET" below, and >> the "save_ip6 = *ip6" within the case AF_INET6 ? That would avoid to >> copy bytes that are not required. > > The issue is that when save_ip is used later on in another switch/case, > the compiler will warn that save_ip may be used uninitialized, because > the compiler is not smart enough to realize that the two codes are under > the same conditions. It seems to happen that my current version of gcc > doesn't warn about save_ip, but it does warn about ip if I moved that > too for instance. So we can move the assignment indeed, but there will > probably be some compilers which will emit a warning here, I don't know > what we prefer. If current compilers only complain about the "ip = ..." statement, then I'd suggest to give it a try to only move the "save_ip = ..." statements into the switch cases (I think it's worth a try since this is the more expensive operation). If that causes trouble later, we can still move the statements back (or maybe fix the warnings by other means). Thomas