From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjNOd-0001f7-33 for qemu-devel@nongnu.org; Mon, 12 Sep 2016 05:19:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjNOa-0002ik-Ul for qemu-devel@nongnu.org; Mon, 12 Sep 2016 05:19:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjNOa-0002iZ-Q0 for qemu-devel@nongnu.org; Mon, 12 Sep 2016 05:19:20 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 74435C0096E5 for ; Mon, 12 Sep 2016 09:19:20 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 12 Sep 2016 13:18:56 +0400 Message-Id: <20160912091913.15831-2-marcandre.lureau@redhat.com> In-Reply-To: <20160912091913.15831-1-marcandre.lureau@redhat.com> References: <20160912091913.15831-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [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: qemu-devel@nongnu.org Cc: eblake@redhat.com, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= There are better chances to find what went wrong at build time than a later assert in qmp_query_version Signed-off-by: Marc-Andr=C3=A9 Lureau --- qmp.c | 16 +++------------- scripts/create_config | 6 ++++++ 2 files changed, 9 insertions(+), 13 deletions(-) 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 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->minor); - 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 return info; 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" ;; qemu_*dir=3D*) # qemu-specific directory configuration name=3D${line%=3D*} --=20 2.10.0