From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VuK4h-0004gD-SJ for qemu-devel@nongnu.org; Sat, 21 Dec 2013 05:46:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VuK4b-0001J2-Rv for qemu-devel@nongnu.org; Sat, 21 Dec 2013 05:46:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VuK4b-0001Iy-J2 for qemu-devel@nongnu.org; Sat, 21 Dec 2013 05:46:21 -0500 From: Markus Armbruster References: <1387520990-3228-1-git-send-email-qiudayu@linux.vnet.ibm.com> Date: Sat, 21 Dec 2013 11:46:16 +0100 In-Reply-To: <1387520990-3228-1-git-send-email-qiudayu@linux.vnet.ibm.com> (Mike Qiu's message of "Fri, 20 Dec 2013 01:29:50 -0500") Message-ID: <87fvpmlbwn.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] vl: Fix compile issue with Werror option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mike Qiu Cc: qemu-devel@nongnu.org, aliguori@amazon.com Mike Qiu writes: > Currently, if compile with Werror option, the error message shows > below: > > GEN config-host.h > GEN trace/generated-tracers.h > CHK version_gen.h > GEN trace/generated-tracers.c > CC vl.o > vl.c: In function =E2=80=98get_boot_devices_list=E2=80=99: > vl.c:1257:21: error: =E2=80=98bootpath=E2=80=99 may be used uninitialized > in this function [-Werror=3Dmaybe-uninitialized] > len =3D strlen(bootpath) + 1; > ^ > cc1: all warnings being treated as errors > make: *** [vl.o] Error 1 > > This patch is to solve this issue. > > Signed-off-by: Mike Qiu > --- > vl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/vl.c b/vl.c > index b97728f..d67b284 100644 > --- a/vl.c > +++ b/vl.c > @@ -1230,7 +1230,7 @@ char *get_boot_devices_list(size_t *size, bool igno= re_suffixes) > char *list =3D NULL; >=20=20 > QTAILQ_FOREACH(i, &fw_boot_order, link) { > - char *devpath =3D NULL, *bootpath; > + char *devpath =3D NULL, *bootpath =3D NULL; > size_t len; >=20=20 > if (i->dev) { Compiler version? I'm asking because bootpath looks quite defined on all paths leading to the line you quoted: QTAILQ_FOREACH(i, &fw_boot_order, link) { char *devpath =3D NULL, *bootpath; size_t len; if (i->dev) { devpath =3D qdev_get_fw_dev_path(i->dev); assert(devpath); } if (i->suffix && devpath) { size_t bootpathlen =3D strlen(devpath) + strlen(i->suffix) + 1; ---> bootpath =3D g_malloc(bootpathlen); snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix); g_free(devpath); } else if (devpath) { ---> bootpath =3D devpath; } else { assert(i->suffix); ---> bootpath =3D g_strdup(i->suffix); } if (total) { list[total-1] =3D '\n'; } len =3D strlen(bootpath) + 1;