From nobody Sat Oct 25 21:42:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521490716858698.3804619952926; Mon, 19 Mar 2018 13:18:36 -0700 (PDT) Received: from localhost ([::1]:43729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey1En-00065x-OT for importer@patchew.org; Mon, 19 Mar 2018 16:18:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey19u-0002Ue-Qs for qemu-devel@nongnu.org; Mon, 19 Mar 2018 16:13:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ey19q-0006w3-0j for qemu-devel@nongnu.org; Mon, 19 Mar 2018 16:13:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9217) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ey19p-0006vb-Ql for qemu-devel@nongnu.org; Mon, 19 Mar 2018 16:13:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2236CC057F91; Mon, 19 Mar 2018 20:13:25 +0000 (UTC) Received: from localhost (ovpn-116-4.gru2.redhat.com [10.97.116.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD79560BE3; Mon, 19 Mar 2018 20:13:20 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Mon, 19 Mar 2018 17:12:54 -0300 Message-Id: <20180319201255.9317-7-ehabkost@redhat.com> In-Reply-To: <20180319201255.9317-1-ehabkost@redhat.com> References: <20180319201255.9317-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 19 Mar 2018 20:13:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 6/7] cpu: drop unnecessary NULL check and cpu_common_class_by_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: Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov both do nothing as for the first all callers parse_cpu_model() and qmp_query_cpu_model_() should provide non NULL value, so just abort if it's not so. While at it drop cpu_common_class_by_name() which is not need any more as every target has CPUClass::class_by_name callback by now, though abort in case a new arch will forget to define one. Signed-off-by: Igor Mammedov Message-Id: <1518013857-4372-1-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- qom/cpu.c | 14 ++------------ target/i386/cpu.c | 8 +------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/qom/cpu.c b/qom/cpu.c index 60292dfde9..92599f3541 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -286,21 +286,12 @@ static bool cpu_common_has_work(CPUState *cs) =20 ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model) { - CPUClass *cc; - - if (!cpu_model) { - return NULL; - } - cc =3D CPU_CLASS(object_class_by_name(typename)); + CPUClass *cc =3D CPU_CLASS(object_class_by_name(typename)); =20 + assert(cpu_model && cc->class_by_name); return cc->class_by_name(cpu_model); } =20 -static ObjectClass *cpu_common_class_by_name(const char *cpu_model) -{ - return NULL; -} - static void cpu_common_parse_features(const char *typename, char *features, Error **errp) { @@ -418,7 +409,6 @@ static void cpu_class_init(ObjectClass *klass, void *da= ta) DeviceClass *dc =3D DEVICE_CLASS(klass); CPUClass *k =3D CPU_CLASS(klass); =20 - k->class_by_name =3D cpu_common_class_by_name; k->parse_features =3D cpu_common_parse_features; k->reset =3D cpu_common_reset; k->get_arch_id =3D cpu_common_get_arch_id; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6bb4ce8719..30b4af897b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -781,13 +781,7 @@ static char *x86_cpu_type_name(const char *model_name) static ObjectClass *x86_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; - char *typename; - - if (cpu_model =3D=3D NULL) { - return NULL; - } - - typename =3D x86_cpu_type_name(cpu_model); + char *typename =3D x86_cpu_type_name(cpu_model); oc =3D object_class_by_name(typename); g_free(typename); return oc; --=20 2.14.3