From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Samuel Thibault <samuel.thibault@gnu.org>
Cc: qemu-devel@nongnu.org, jan.kiszka@siemens.com
Subject: Re: [Qemu-devel] [PATCH] slirp: Gcc 9 -O3 fix
Date: Mon, 8 Apr 2019 09:46:53 +0100 [thread overview]
Message-ID: <20190408084653.GB2687@work-vm> (raw)
In-Reply-To: <20190405212501.cdg4u3m7ihldcop4@function>
* Samuel Thibault (samuel.thibault@gnu.org) wrote:
> Hello,
>
> Dr. David Alan Gilbert (git), le ven. 05 avril 2019 19:46:48 +0100, a ecrit:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > Gcc 9 needs some convincing that sopreprbuf really is going to fill
> > in iov in the call from soreadbuf, even though the failure case
> > shouldn't happen; so swing the check around initialising the fields.
>
> While I can understand that setting iov[0].iov_len may help a compiler,
> I don't see why moving if (len <= 0) return 0; down?
The original errors are:
/home/dgilbert/git/qemu/slirp/src/socket.c: In function ‘soread’:
/home/dgilbert/git/qemu/slirp/src/socket.c:188:7: error: ‘iov.iov_base’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
188 | nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dgilbert/git/qemu/slirp/src/socket.c:188:7: error: ‘iov.iov_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
/home/dgilbert/git/qemu/slirp/src/socket.c:232:5: error: ‘n’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
232 | if (n == 2 && nn == iov[0].iov_len) {
| ^
/home/dgilbert/git/qemu/slirp/src/socket.c:234:19: error: ‘*((void *)&iov+16).iov_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
(and a few more along the same idea).
So the problem is actually in soread not sopreprbuf itself.
'soread' has the comment:
/*
* No need to check if there's enough room to read.
* soread wouldn't have been called if there weren't
*/
sopreprbuf(so, iov, &n);
the compiler doesn't realise that, and is moaning about the case
where the if (len <=0) return happens and the following
code tries to use iov.
Dave
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > ---
> > slirp/src/socket.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/slirp/src/socket.c b/slirp/src/socket.c
> > index 4a3c935e25..4a2222a95f 100644
> > --- a/slirp/src/socket.c
> > +++ b/slirp/src/socket.c
> > @@ -113,12 +113,14 @@ size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np)
> > DEBUG_CALL("sopreprbuf");
> > DEBUG_ARG("so = %p", so);
> >
> > - if (len <= 0)
> > - return 0;
> > -
> > iov[0].iov_base = sb->sb_wptr;
> > + iov[0].iov_len = 0;
> > iov[1].iov_base = NULL;
> > iov[1].iov_len = 0;
> > +
> > + if (len <= 0)
> > + return 0;
> > +
> > if (sb->sb_wptr < sb->sb_rptr) {
> > iov[0].iov_len = sb->sb_rptr - sb->sb_wptr;
> > /* Should never succeed, but... */
> > --
> > 2.21.0
> >
>
> --
> Samuel
> FYLG> Tiens, vlà une URL qui va bien :
> FYLG> ftp://127.0.0.1/WaReZ/NiouZeS/WinDoZe/NeWSMoNGeR/SuPeR
> c'est gentil sauf que l'adresse ne fonctionne pas sa me fais une erreur
> -+- Furtif in Guide du Neuneu Usenet : <MODE CERVEAU OFF> -+-
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
WARNING: multiple messages have this Message-ID (diff)
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Samuel Thibault <samuel.thibault@gnu.org>
Cc: jan.kiszka@siemens.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] slirp: Gcc 9 -O3 fix
Date: Mon, 8 Apr 2019 09:46:53 +0100 [thread overview]
Message-ID: <20190408084653.GB2687@work-vm> (raw)
Message-ID: <20190408084653.g21IlJQR_yMtHk6O2BXwzO3AMBzCnuWDGbX2Egh1YA4@z> (raw)
In-Reply-To: <20190405212501.cdg4u3m7ihldcop4@function>
* Samuel Thibault (samuel.thibault@gnu.org) wrote:
> Hello,
>
> Dr. David Alan Gilbert (git), le ven. 05 avril 2019 19:46:48 +0100, a ecrit:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > Gcc 9 needs some convincing that sopreprbuf really is going to fill
> > in iov in the call from soreadbuf, even though the failure case
> > shouldn't happen; so swing the check around initialising the fields.
>
> While I can understand that setting iov[0].iov_len may help a compiler,
> I don't see why moving if (len <= 0) return 0; down?
The original errors are:
/home/dgilbert/git/qemu/slirp/src/socket.c: In function ‘soread’:
/home/dgilbert/git/qemu/slirp/src/socket.c:188:7: error: ‘iov.iov_base’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
188 | nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dgilbert/git/qemu/slirp/src/socket.c:188:7: error: ‘iov.iov_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
/home/dgilbert/git/qemu/slirp/src/socket.c:232:5: error: ‘n’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
232 | if (n == 2 && nn == iov[0].iov_len) {
| ^
/home/dgilbert/git/qemu/slirp/src/socket.c:234:19: error: ‘*((void *)&iov+16).iov_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
(and a few more along the same idea).
So the problem is actually in soread not sopreprbuf itself.
'soread' has the comment:
/*
* No need to check if there's enough room to read.
* soread wouldn't have been called if there weren't
*/
sopreprbuf(so, iov, &n);
the compiler doesn't realise that, and is moaning about the case
where the if (len <=0) return happens and the following
code tries to use iov.
Dave
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > ---
> > slirp/src/socket.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/slirp/src/socket.c b/slirp/src/socket.c
> > index 4a3c935e25..4a2222a95f 100644
> > --- a/slirp/src/socket.c
> > +++ b/slirp/src/socket.c
> > @@ -113,12 +113,14 @@ size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np)
> > DEBUG_CALL("sopreprbuf");
> > DEBUG_ARG("so = %p", so);
> >
> > - if (len <= 0)
> > - return 0;
> > -
> > iov[0].iov_base = sb->sb_wptr;
> > + iov[0].iov_len = 0;
> > iov[1].iov_base = NULL;
> > iov[1].iov_len = 0;
> > +
> > + if (len <= 0)
> > + return 0;
> > +
> > if (sb->sb_wptr < sb->sb_rptr) {
> > iov[0].iov_len = sb->sb_rptr - sb->sb_wptr;
> > /* Should never succeed, but... */
> > --
> > 2.21.0
> >
>
> --
> Samuel
> FYLG> Tiens, vlà une URL qui va bien :
> FYLG> ftp://127.0.0.1/WaReZ/NiouZeS/WinDoZe/NeWSMoNGeR/SuPeR
> c'est gentil sauf que l'adresse ne fonctionne pas sa me fais une erreur
> -+- Furtif in Guide du Neuneu Usenet : <MODE CERVEAU OFF> -+-
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2019-04-08 8:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-05 18:46 [Qemu-devel] [PATCH] slirp: Gcc 9 -O3 fix Dr. David Alan Gilbert (git)
2019-04-05 19:08 ` no-reply
2019-04-05 19:08 ` no-reply
2019-04-05 21:25 ` Samuel Thibault
2019-04-05 21:25 ` Samuel Thibault
2019-04-08 8:46 ` Dr. David Alan Gilbert [this message]
2019-04-08 8:46 ` Dr. David Alan Gilbert
2019-04-11 18:45 ` Samuel Thibault
2019-04-11 18:45 ` Samuel Thibault
2019-04-12 15:49 ` Dr. David Alan Gilbert
2019-04-12 15:49 ` Dr. David Alan Gilbert
2019-04-12 21:16 ` Samuel Thibault
2019-04-12 21:16 ` Samuel Thibault
2019-04-15 12:02 ` Dr. David Alan Gilbert
2019-04-15 12:02 ` Dr. David Alan Gilbert
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=20190408084653.GB2687@work-vm \
--to=dgilbert@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
--cc=samuel.thibault@gnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.