From nobody Sun Apr 28 17:39:41 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15234688718131022.0296192569466; Wed, 11 Apr 2018 10:47:51 -0700 (PDT) Received: from localhost ([::1]:44086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6JqV-00067C-6C for importer@patchew.org; Wed, 11 Apr 2018 13:47:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6JpA-0005dq-2g for qemu-devel@nongnu.org; Wed, 11 Apr 2018 13:46:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6Jp5-0005RH-Cy for qemu-devel@nongnu.org; Wed, 11 Apr 2018 13:46:24 -0400 Received: from 5.mo5.mail-out.ovh.net ([87.98.173.103]:35768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f6Jp5-0005QS-80 for qemu-devel@nongnu.org; Wed, 11 Apr 2018 13:46:19 -0400 Received: from player760.ha.ovh.net (unknown [10.109.122.33]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 295971A17FE for ; Wed, 11 Apr 2018 19:46:17 +0200 (CEST) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 839E520083; Wed, 11 Apr 2018 19:46:12 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 11 Apr 2018 19:46:06 +0200 Message-ID: <152346876630.89534.10956847520017803741.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 5325506562607847763 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtgedrheekgdduudekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.173.103 Subject: [Qemu-devel] [PATCH] spapr: drop useless sanity check in spapr_irq_alloc*() 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: qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Both spapr_irq_alloc() and spapr_irq_alloc_block() have an errp parameter, but they don't use it if XICS hasn't been initialized yet. This is doubly wrong: - all callers do pass a non-null Error **, ie, they expect an error to be propagated in case of failure - XICS obviously needs to be initialized before anything starts allocating IRQs So this patch turns the check into an assert. Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 4d27909fb152..799673319b06 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3707,9 +3707,8 @@ int spapr_irq_alloc(sPAPRMachineState *spapr, int irq= _hint, bool lsi, ICSState *ics =3D spapr->ics; int irq; =20 - if (!ics) { - return -1; - } + assert(ics); + if (irq_hint) { if (!ICS_IRQ_FREE(ics, irq_hint - ics->offset)) { error_setg(errp, "can't allocate IRQ %d: already in use", irq_= hint); @@ -3741,9 +3740,7 @@ int spapr_irq_alloc_block(sPAPRMachineState *spapr, i= nt num, bool lsi, ICSState *ics =3D spapr->ics; int i, first =3D -1; =20 - if (!ics) { - return -1; - } + assert(ics); =20 /* * MSIMesage::data is used for storing VIRQ so