From nobody Sat May 4 11:23:08 2024 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 1518014327110739.198171110553; Wed, 7 Feb 2018 06:38:47 -0800 (PST) Received: from localhost ([::1]:45866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejQs2-0001iT-6s for importer@patchew.org; Wed, 07 Feb 2018 09:38:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejQm2-0005E6-Lf for qemu-devel@nongnu.org; Wed, 07 Feb 2018 09:32:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejQly-0005NW-Mt for qemu-devel@nongnu.org; Wed, 07 Feb 2018 09:32:34 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60132 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejQly-0005NL-Id for qemu-devel@nongnu.org; Wed, 07 Feb 2018 09:32:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3189E40201A0 for ; Wed, 7 Feb 2018 14:32:30 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABBF3AB585; Wed, 7 Feb 2018 14:32:29 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Wed, 7 Feb 2018 15:30:57 +0100 Message-Id: <1518013857-4372-1-git-send-email-imammedo@redhat.com> In-Reply-To: <20180207125710.GJ3291@localhost.localdomain> References: <20180207125710.GJ3291@localhost.localdomain> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 07 Feb 2018 14:32:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 07 Feb 2018 14:32:30 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] 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: ehabkost@redhat.com 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" 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 Reviewed-by: Eduardo Habkost --- isn't really tested but it compiles and passes make check 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 60292df..92599f3 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 a49d222..61d915b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -740,13 +740,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.7.4