From nobody Sun Feb 8 21:28:32 2026 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 1518461789464524.9811522720724; Mon, 12 Feb 2018 10:56:29 -0800 (PST) Received: from localhost ([::1]:39429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elJHA-0005Qj-Jn for importer@patchew.org; Mon, 12 Feb 2018 13:56:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elJF0-0003xR-EB for qemu-devel@nongnu.org; Mon, 12 Feb 2018 13:54:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elJEz-0004p9-3l for qemu-devel@nongnu.org; Mon, 12 Feb 2018 13:54:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49726) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1elJEy-0004oC-TX for qemu-devel@nongnu.org; Mon, 12 Feb 2018 13:54:13 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E8A94B95; Mon, 12 Feb 2018 18:54:12 +0000 (UTC) Received: from localhost (ovpn-116-12.gru2.redhat.com [10.97.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6663600D1; Mon, 12 Feb 2018 18:54:11 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Mon, 12 Feb 2018 16:53:47 -0200 Message-Id: <20180212185347.8433-8-ehabkost@redhat.com> In-Reply-To: <20180212185347.8433-1-ehabkost@redhat.com> References: <20180212185347.8433-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 12 Feb 2018 18:54:12 +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 7/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 , 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 b5e431e769..acc853c871 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -741,13 +741,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