From 4752cdbbf330ac7c593a6f337b97a79648f3f878 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 4 May 2015 09:05:31 -0600 Subject: qapi: Drop inline nested struct in query-version A future patch will be using a 'name':{dictionary} entry in the QAPI schema to specify a default value for an optional argument (see previous commit message for more details why); but existing use of inline nested structs conflicts with that goal. This patch fixes one of only two commands relying on nested types, by breaking the nesting into an explicit type; it means that the type is now boxed instead of unboxed in C code, but the QMP wire format is unaffected by this change. Prefer the safer g_new0() while making the conversion. Signed-off-by: Eric Blake Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- qmp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'qmp.c') diff --git a/qmp.c b/qmp.c index e6c7050..3f5dfe3 100644 --- a/qmp.c +++ b/qmp.c @@ -45,15 +45,16 @@ NameInfo *qmp_query_name(Error **errp) VersionInfo *qmp_query_version(Error **errp) { - VersionInfo *info = g_malloc0(sizeof(*info)); + VersionInfo *info = g_new0(VersionInfo, 1); const char *version = QEMU_VERSION; char *tmp; - info->qemu.major = strtol(version, &tmp, 10); + info->qemu = g_new0(VersionTriple, 1); + info->qemu->major = strtol(version, &tmp, 10); tmp++; - info->qemu.minor = strtol(tmp, &tmp, 10); + info->qemu->minor = strtol(tmp, &tmp, 10); tmp++; - info->qemu.micro = strtol(tmp, &tmp, 10); + info->qemu->micro = strtol(tmp, &tmp, 10); info->package = g_strdup(QEMU_PKGVERSION); return info; -- cgit v1.1