From patchwork Fri Aug 5 08:24:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 656090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s5LFW05Nyz9t0Z for ; Fri, 5 Aug 2016 18:53:51 +1000 (AEST) Received: from localhost ([::1]:43493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVat2-0004lZ-UM for incoming@patchwork.ozlabs.org; Fri, 05 Aug 2016 04:53:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVaRz-0002Sr-Ls for qemu-devel@nongnu.org; Fri, 05 Aug 2016 04:25:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVaRx-0002Ji-Lo for qemu-devel@nongnu.org; Fri, 05 Aug 2016 04:25:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVaRx-0002JW-Fc for qemu-devel@nongnu.org; Fri, 05 Aug 2016 04:25:49 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 2581EC04D2A5 for ; Fri, 5 Aug 2016 08:25:49 +0000 (UTC) Received: from localhost (ovpn-116-55.phx2.redhat.com [10.3.116.55]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u758PlM8028987; Fri, 5 Aug 2016 04:25:48 -0400 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 5 Aug 2016 12:24:02 +0400 Message-Id: <20160805082421.21994-18-marcandre.lureau@redhat.com> In-Reply-To: <20160805082421.21994-1-marcandre.lureau@redhat.com> References: <20160805082421.21994-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 05 Aug 2016 08:25:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.7 v4 17/36] machine: use class base init generated name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau machine_class_base_init() member name is allocated by machine_class_base_init(), but not freed by machine_class_finalize(). Simply freeing there doesn't work, because DEFINE_PC_MACHINE() overwrites it with a literal string. Fix DEFINE_PC_MACHINE() not to overwrite it, and add the missing free to machine_class_finalize(). Signed-off-by: Marc-André Lureau Reviewed-by: Markus Armbruster --- hw/core/machine.c | 1 + include/hw/boards.h | 2 +- include/hw/i386/pc.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index e5a456f..00fbe3e 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -561,6 +561,7 @@ static void machine_class_finalize(ObjectClass *klass, void *data) if (mc->compat_props) { g_array_free(mc->compat_props, true); } + g_free(mc->name); } void machine_register_compat_props(MachineState *machine) diff --git a/include/hw/boards.h b/include/hw/boards.h index 3e69eca..e46a744 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -93,7 +93,7 @@ struct MachineClass { /*< public >*/ const char *family; /* NULL iff @name identifies a standalone machtype */ - const char *name; + char *name; const char *alias; const char *desc; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 330c1f2..422fac7 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -903,7 +903,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); { \ MachineClass *mc = MACHINE_CLASS(oc); \ optsfn(mc); \ - mc->name = namestr; \ mc->init = initfn; \ } \ static const TypeInfo pc_machine_type_##suffix = { \