From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrIPl-0004Q4-Rk for qemu-devel@nongnu.org; Mon, 24 Jun 2013 21:51:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UrIPk-0007Kp-1j for qemu-devel@nongnu.org; Mon, 24 Jun 2013 21:51:25 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:37327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrIPj-0007HC-Dh for qemu-devel@nongnu.org; Mon, 24 Jun 2013 21:51:23 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Jun 2013 22:47:35 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 5073D2BB0044 for ; Tue, 25 Jun 2013 11:51:17 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5P1aRuZ7995806 for ; Tue, 25 Jun 2013 11:36:28 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5P1pG42004635 for ; Tue, 25 Jun 2013 11:51:16 +1000 Message-ID: <51C8F779.20201@linux.vnet.ibm.com> Date: Tue, 25 Jun 2013 09:50:49 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1370599329-16682-1-git-send-email-xiawenc@linux.vnet.ibm.com> <87ehcedsi7.fsf@blackfin.pond.sub.org> <51C032D2.80405@redhat.com> <51C5766F.8000704@weilnetz.de> <51C85B5D.7050702@redhat.com> In-Reply-To: <51C85B5D.7050702@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH V2] build: remove compile warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, Stefan Weil , qemu-devel@nongnu.org, Markus Armbruster , alevy@redhat.com, stefanha@redhat.com, mlureau@redhat.com, Robert Relyea 于 2013-6-24 22:44, Paolo Bonzini 写道: > Il 22/06/2013 12:03, Stefan Weil ha scritto: >> Am 18.06.2013 12:13, schrieb Paolo Bonzini: >>> Il 07/06/2013 14:17, Markus Armbruster ha scritto: >>>>> diff --git a/util/iov.c b/util/iov.c >>>>> index cc6e837..b91cfb9 100644 >>>>> --- a/util/iov.c >>>>> +++ b/util/iov.c >>>>> @@ -146,7 +146,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, >>>>> { >>>>> ssize_t total = 0; >>>>> ssize_t ret; >>>>> - size_t orig_len, tail; >>>>> + size_t orig_len = 0, tail; >>>>> unsigned niov; >>>>> >>>>> while (bytes > 0) { >>>> Here are the uses of orig_len: >>>> >>>> if (tail) { >>>> /* second, fixup the last element, and remember the original >>>> * length */ >>>> assert(niov < iov_cnt); >>>> assert(iov[niov].iov_len > tail); >>>> orig_len = iov[niov].iov_len; >>>> iov[niov++].iov_len = tail; >>>> } >>>> >>>> ret = do_send_recv(sockfd, iov, niov, do_send); >>>> >>>> /* Undo the changes above before checking for errors */ >>>> if (tail) { >>>> iov[niov-1].iov_len = orig_len; >>>> } >>>> >>>> >> >> I get this warning, too, when I run a normal cross compilation with >> MinGW-w64: >> >> util/iov.c:190:33: warning: ‘orig_len’ may be used uninitialized in this >> function [-Wuninitialized] >> >> My build environment: >> >> Debian wheezy with packages gcc-mingw-w64-i686, gcc-mingw-w64-x86-64 >> (4.6.3-14+8). >> >> A complete build results in 5 warnings. Here are the other 4 of them: >> >> hw/arm/spitz.c:280:0: warning: "MOD_SHIFT" redefined [enabled by default] >> hw/ppc/spapr.c:673:26: warning: cast from pointer to integer of >> different size [-Wpointer-to-int-cast] > > Isn't this one a Win64 bug? > >> hw/ppc/spapr_hcall.c:188:1: warning: control reaches end of non-void >> function [-Wreturn-type] >> hw/ppc/spapr_pci.c:454:1: warning: control reaches end of non-void >> function [-Wreturn-type] > > I think you could report this to mingw. GCC should handle "if (!0) > foo()" just fine if foo is noreturn, perhaps the "assertion failure" > runtime function is not noreturn in mingw. > >> I already sent a patch for the MOD_SHIFT issue. >> >> The remaining 3 warnings are also caused by code which makes it difficult >> for the compiler to detect that it is correct. > > Not as hard as this one, though. > > Anyway, I would be okay a fix that makes the code easier to follow for > compilers (and doesn't have too much duplication so that humans are also > happy). But adding "= 0" is the worst, because smart compilers will not > detect a human's mistakes anymore. > > Paolo > Hi Palo, There is V3 remove uninitlized warning without adding "= 0", could u take a look for it? http://lists.nongnu.org/archive/html/qemu-devel/2013-06/msg02348.html -- Best Regards Wenchao Xia