From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqKfU-0002E4-R8 for qemu-devel@nongnu.org; Sat, 22 Jun 2013 06:03:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UqKfS-0008Ik-Ad for qemu-devel@nongnu.org; Sat, 22 Jun 2013 06:03:40 -0400 Received: from [2a03:4000:1::4e2f:c7ac:d] (port=54321 helo=v220110690675601.yourvserver.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqKfS-0008Ib-4Z for qemu-devel@nongnu.org; Sat, 22 Jun 2013 06:03:38 -0400 Message-ID: <51C5766F.8000704@weilnetz.de> Date: Sat, 22 Jun 2013 12:03:27 +0200 From: Stefan Weil 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> In-Reply-To: <51C032D2.80405@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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, Wenchao Xia , Markus Armbruster , qemu-devel@nongnu.org, alevy@redhat.com, stefanha@redhat.com, mlureau@redhat.com, Robert Relyea 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 *i= ov, unsigned iov_cnt, >>> { >>> ssize_t total =3D 0; >>> ssize_t ret; >>> - size_t orig_len, tail; >>> + size_t orig_len =3D 0, tail; >>> unsigned niov; >>> =20 >>> while (bytes > 0) { >> Here are the uses of orig_len: >> >> if (tail) { >> /* second, fixup the last element, and remember the origin= al >> * length */ >> assert(niov < iov_cnt); >> assert(iov[niov].iov_len > tail); >> orig_len =3D iov[niov].iov_len; >> iov[niov++].iov_len =3D tail; >> } >> >> ret =3D do_send_recv(sockfd, iov, niov, do_send); >> >> /* Undo the changes above before checking for errors */ >> if (tail) { >> iov[niov-1].iov_len =3D orig_len; >> } >> >> >> gcc is too stupid to understand the control flow. The initialization >> shuts it up. > Looks like most people's GCC is not that stupid, or I would have broken > build for everyone, right? > > Paolo Hi Paolo, I get this warning, too, when I run a normal cross compilation with MinGW-w64: util/iov.c:190:33: warning: =E2=80=98orig_len=E2=80=99 may be used uninit= ialized 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] 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 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. Regards Stefan