From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMyAJ-0000z6-Nb for qemu-devel@nongnu.org; Fri, 20 Sep 2013 06:42:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMyAD-0004mC-VJ for qemu-devel@nongnu.org; Fri, 20 Sep 2013 06:42:23 -0400 Date: Fri, 20 Sep 2013 12:42:14 +0200 From: Stefan Hajnoczi Message-ID: <20130920104214.GB14159@stefanha-thinkpad.redhat.com> References: <1379436196-27506-1-git-send-email-sw@weilnetz.de> <523B2D6B.9050601@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <523B2D6B.9050601@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] block: Fix compiler warning (-Werror=uninitialized) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: qemu-trivial , Stefan Weil , qemu-devel , Kevin Wolf On Thu, Sep 19, 2013 at 06:59:23PM +0200, Andreas F=C3=A4rber wrote: > Am 17.09.2013 18:43, schrieb Stefan Weil: > > The patch fixes a warning from gcc (Debian 4.6.3-14+rpi1) 4.6.3: > >=20 > > block/stream.c:141:22: error: > > =E2=80=98copy=E2=80=99 may be used uninitialized in this function [-W= error=3Duninitialized] > >=20 > > This is not a real bug - a better compiler would not complain. > >=20 > > Now 'copy' has always a defined value, so the check for ret >=3D 0 > > can be removed. > >=20 > > Signed-off-by: Stefan Weil > > --- > > block/stream.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > >=20 > > diff --git a/block/stream.c b/block/stream.c > > index 078ce4a..fc19194 100644 > > --- a/block/stream.c > > +++ b/block/stream.c > > @@ -108,7 +108,7 @@ static void coroutine_fn stream_run(void *opaque) > > =20 > > for (sector_num =3D 0; sector_num < end; sector_num +=3D n) { > > uint64_t delay_ns =3D 0; > > - bool copy; > > + bool copy =3D false; > > =20 > > wait: > > /* Note that even when no rate limit is applied we need to y= ield > > @@ -123,7 +123,6 @@ wait: > > STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZ= E, &n); > > if (ret =3D=3D 1) { > > /* Allocated in the top, no need to copy. */ > > - copy =3D false; > > } else if (ret >=3D 0) { > > /* Copy if allocated in the intermediate images. Limit = to the > > * known-unallocated area [sector_num, sector_num+n). *= / >=20 > Sorry for not spotting this patch earlier. This hunk looks wrong and > needs to be dropped, I believe. In the ret >=3D 0 && copy case, there i= s a > "goto wait" which would now no longer be able to go from copy =3D=3D tr= ue -> > copy =3D=3D false. Not sure if that can happen in practice. Thanks for catching this! I've dropped the patch from my block tree for now. Stefan