From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7010C433E0 for ; Thu, 7 Jan 2021 08:09:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED8B823125 for ; Thu, 7 Jan 2021 08:09:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED8B823125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kaod.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxQMj-0007Ha-SW for qemu-devel@archiver.kernel.org; Thu, 07 Jan 2021 03:09:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxQLO-0006Mu-9z for qemu-devel@nongnu.org; Thu, 07 Jan 2021 03:08:30 -0500 Received: from 3.mo52.mail-out.ovh.net ([178.33.254.192]:40889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxQLF-0000sU-PA for qemu-devel@nongnu.org; Thu, 07 Jan 2021 03:08:30 -0500 Received: from mxplan5.mail.ovh.net (unknown [10.108.4.89]) by mo52.mail-out.ovh.net (Postfix) with ESMTPS id 8636522E5F7; Thu, 7 Jan 2021 09:08:17 +0100 (CET) Received: from kaod.org (37.59.142.103) by DAG8EX1.mxp5.local (172.16.2.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Thu, 7 Jan 2021 09:08:16 +0100 Authentication-Results: garm.ovh; auth=pass (GARM-103G00512650ed1-2b06-4406-a2ea-d86f78b1f577, 60F1A555FF7AE05BC39886BDE76A51AB2B051214) smtp.auth=groug@kaod.org X-OVh-ClientIp: 82.253.208.248 Date: Thu, 7 Jan 2021 09:08:15 +0100 From: Greg Kurz To: BALATON Zoltan via Subject: Re: [PATCH 3/3] sam460ex: Use type cast macro instead of simple cast Message-ID: <20210107090815.12cc73fd@bahia.lan> In-Reply-To: <8bc87f574759a3e9e9e8707b1e0947c1ee21fa8c.1609946641.git.balaton@eik.bme.hu> References: <8bc87f574759a3e9e9e8707b1e0947c1ee21fa8c.1609946641.git.balaton@eik.bme.hu> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [37.59.142.103] X-ClientProxiedBy: DAG9EX1.mxp5.local (172.16.2.81) To DAG8EX1.mxp5.local (172.16.2.71) X-Ovh-Tracer-GUID: 13d8f254-ad53-48d7-853f-521abb7cafbc X-Ovh-Tracer-Id: 13938922322658433318 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedujedrvdeguddgfeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepfffhvffukfgjfhfogggtgfhisehtjeertdertddvnecuhfhrohhmpefirhgvghcumfhurhiiuceoghhrohhugheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeefuddtieejjeevheekieeltefgleetkeetheettdeifeffvefhffelffdtfeeljeenucfkpheptddrtddrtddrtddpfeejrdehledrudegvddruddtfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehmgihplhgrnhehrdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepghhrohhugheskhgrohgurdhorhhgpdhrtghpthhtohepuggrvhhiugesghhisghsohhnrdgurhhophgsvggrrhdrihgurdgruh Received-SPF: pass client-ip=178.33.254.192; envelope-from=groug@kaod.org; helo=3.mo52.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , f4bug@amsat.org, qemu-devel@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, 6 Jan 2021 16:24:01 +0100 BALATON Zoltan via wrote: > Use the PCI_BUS type cast macro to convert result of > qdev_get_child_bus(). Also remove the check for NULL afterwards which > should not be needed because sysbus_create_simple() uses error_abort It seems to me that sysbus_create_simple() doesn't return NULL because it ends up calling object_new_with_type(). This allocates the object with either g_malloc() or qemu_memalign(), both of which abort on failure. > and PCI_BUS macro also checks its argument by default so this AFAICT, PCI_BUS() and all other instance type checking macros are happy with a NULL argument. They simply return NULL in this case. > shouldn't fail here. > > Signed-off-by: BALATON Zoltan > --- > hw/ppc/sam460ex.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c > index 14e6583eb0..cc67e9c39b 100644 > --- a/hw/ppc/sam460ex.c > +++ b/hw/ppc/sam460ex.c > @@ -384,11 +384,8 @@ static void sam460ex_init(MachineState *machine) > ppc460ex_pcie_init(env); > /* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */ > dev = sysbus_create_simple("ppc440-pcix-host", 0xc0ec00000, uic[1][0]); > - pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); > - if (!pci_bus) { > - error_report("couldn't create PCI controller!"); > - exit(1); > - } > + pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci.0")); > + But PCI_BUS() is being passed qdev_get_child_bus(dev, "pci.0"), not dev... so the real question here is whether this can return NULL or not. And if this happens, is this a (1) user or (2) programming error ? If (1) then the "if (!pci_bus) { }" should be kept. If (2) then it should be converted to an assert(). > memory_region_init_alias(isa, NULL, "isa_mmio", get_system_io(), > 0, 0x10000); > memory_region_add_subregion(get_system_memory(), 0xc08000000, isa);