From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjiE9-0005FR-Mk for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:33:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjiE3-0002om-Nz for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:33:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjiE3-0002oW-GA for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:33:51 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A896C04B317 for ; Tue, 13 Sep 2016 07:33:50 +0000 (UTC) From: Markus Armbruster References: <20160912091913.15831-1-marcandre.lureau@redhat.com> <20160912091913.15831-2-marcandre.lureau@redhat.com> Date: Tue, 13 Sep 2016 09:33:48 +0200 In-Reply-To: (Eric Blake's message of "Mon, 12 Sep 2016 15:05:15 -0500") Message-ID: <87r38ogso3.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 01/18] build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO} List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , qemu-devel@nongnu.org Eric Blake writes: > On 09/12/2016 04:18 AM, Marc-Andr=C3=A9 Lureau wrote: >> There are better chances to find what went wrong at build time than a >> later assert in qmp_query_version >>=20 >> Signed-off-by: Marc-Andr=C3=A9 Lureau >> --- >> qmp.c | 16 +++------------- >> scripts/create_config | 6 ++++++ >> 2 files changed, 9 insertions(+), 13 deletions(-) >>=20 >> diff --git a/qmp.c b/qmp.c >> index dea8f81..6733463 100644 >> --- a/qmp.c >> +++ b/qmp.c >> @@ -51,21 +51,11 @@ NameInfo *qmp_query_name(Error **errp) >> VersionInfo *qmp_query_version(Error **errp) >> { >> VersionInfo *info =3D g_new0(VersionInfo, 1); >> - const char *version =3D QEMU_VERSION; >> - const char *tmp; >> - int err; >>=20=20 >> info->qemu =3D g_new0(VersionTriple, 1); >> - err =3D qemu_strtoll(version, &tmp, 10, &info->qemu->major); >> - assert(err =3D=3D 0); >> - tmp++; >> - >> - err =3D qemu_strtoll(tmp, &tmp, 10, &info->qemu->micro); >> - assert(err =3D=3D 0); >> + info->qemu->major =3D QEMU_VERSION_MAJOR; >> + info->qemu->minor =3D QEMU_VERSION_MINOR; >> + info->qemu->micro =3D QEMU_VERSION_MICRO; >> info->package =3D g_strdup(QEMU_PKGVERSION); >>=20=20 >> return info; > > The old code silently ignores any garbage after the third integer (it > populates &tmp, but never checks the value of tmp). It also accepts any separator character between the integers, not just '.'. >> diff --git a/scripts/create_config b/scripts/create_config >> index 1dd6a35..e6929dd 100755 >> --- a/scripts/create_config >> +++ b/scripts/create_config >> @@ -7,7 +7,13 @@ while read line; do >> case $line in >> VERSION=3D*) # configuration >> version=3D${line#*=3D} >> + major=3D$(echo "$version" | cut -d. -f1) >> + minor=3D$(echo "$version" | cut -d. -f2) >> + micro=3D$(echo "$version" | cut -d. -f3) >> echo "#define QEMU_VERSION \"$version\"" >> + echo "#define QEMU_VERSION_MAJOR $major" >> + echo "#define QEMU_VERSION_MINOR $minor" >> + echo "#define QEMU_VERSION_MICRO $micro" > > The new code likewise ignores any fourth field. Nope: $ echo "2.7.50garbage" | cut -d. -f3 50garbage The compiler will choke on info->qemu->micro =3D QEMU_VERSION_MICRO; because it's info->qemu->micro =3D 50garbage; after preprocessing. The commit message could mention that VERSION is now parsed more strictly (configure checks '.', the compiler checks integers), but I guess it's not worth the bother now. > Do we care either way? Unless someone else has a reason for why we > should care, I'm fine with: > Reviewed-by: Eric Blake Does your R-by stand?