qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com,
	Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, alevy@redhat.com, stefanha@redhat.com,
	mlureau@redhat.com, Robert Relyea <rrelyea@redhat.com>
Subject: Re: [Qemu-devel] [PATCH V2] build: remove compile warning
Date: Mon, 24 Jun 2013 16:44:45 +0200	[thread overview]
Message-ID: <51C85B5D.7050702@redhat.com> (raw)
In-Reply-To: <51C5766F.8000704@weilnetz.de>

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

  reply	other threads:[~2013-06-24 14:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 10:02 [Qemu-devel] [PATCH V2] build: remove compile warning Wenchao Xia
2013-06-07 11:35 ` Stefan Hajnoczi
2013-06-07 12:17 ` Markus Armbruster
2013-06-08  2:04   ` Wenchao Xia
2013-06-18 10:14     ` Paolo Bonzini
2013-06-18 10:13   ` Paolo Bonzini
2013-06-19  6:27     ` Wenchao Xia
2013-06-19  9:33       ` Paolo Bonzini
2013-06-22 10:03     ` Stefan Weil
2013-06-24 14:44       ` Paolo Bonzini [this message]
2013-06-24 17:58         ` Stefan Weil
2013-06-26  8:12           ` Paolo Bonzini
2013-06-25  1:50         ` Wenchao Xia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C85B5D.7050702@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alevy@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=mlureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rrelyea@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    --cc=xiawenc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).