From patchwork Mon May 4 10:07:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11525377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A0B8912 for ; Mon, 4 May 2020 10:08:11 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 EA0B020721 for ; Mon, 4 May 2020 10:08:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LBTEMgDf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA0B020721 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jVY0t-0001tn-6D; Mon, 04 May 2020 10:07:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jVY0r-0001ta-Jj for xen-devel@lists.xenproject.org; Mon, 04 May 2020 10:07:49 +0000 X-Inumbo-ID: 183e7d68-8def-11ea-9887-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 183e7d68-8def-11ea-9887-bc764e2007e4; Mon, 04 May 2020 10:07:43 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id l18so9462306wrn.6 for ; Mon, 04 May 2020 03:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3T0kMXUkml3SPOC+ozrWaQIIxf6I2/xjXP4RZGOc7C0=; b=LBTEMgDf21d8EYLLYw4CGG8/pL52gzKDRRi3VpCUJkbuls2ghqJPmeqte7XWNL48LH yjrNEpeDOF2wVYy7hldkagWzQZyJ4GoaA5Xw3rfxXfAT9JUt9c8cNu9LNmG3XRrExNfM fc8NKqKVYT4RuesNvayTEZbl5oTDlvJIiUlfhnMiNe0OXJr50hTT6BDfBeRubK/qchuw V3Mv+fiB8qlXR3PVSs+GjbRyZ51EksoO3hlE8DqHlBz9/TDKBdGBqpvfvMFTF5BejsdB 3pNHSONBxGghtv3FJuU6wXa+q2LpRPbagT1YWxHvcfEJyDFnzPDeLEK6EnH4dwSG3kcv U8YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3T0kMXUkml3SPOC+ozrWaQIIxf6I2/xjXP4RZGOc7C0=; b=dM0gePsuHcvemONPQBydk3fA/q+UghoTVUlcZKB0Pem9VzJQqAN2rTQwgu5A15CKlc Fx4V/MpsAvdfaxeLbeiUuWenvMRUlVS874UkEgJM4bZGjbOnqEnwrrCmY8atcpjgUclG RIBTZ3XGPuEdZxKmqvPiIE8fOGY7nkFwCJMl4eD8SKjX4JE7Q3yxUVDvoJd/w1In4DO2 ynR7w6E1XzAiO2jNawlnVHL2NbjOgN+VGCkPiq6T6SfYV+zF+tB1DGEefFQf5Kd9JJG4 67MBnu7w89ozWXlcA5nFCIuXZLMS/yltCdTWccnd014Abur6clAeFSAXLCDdRmMNE9py Tl4A== X-Gm-Message-State: AGi0PubKz1hyyy1Jb9OBLV7SZUMxizZUb+Mr1UH4c75D9W3saLkyo20C yBl4WPqDzmw3S2ULClB7/xU= X-Google-Smtp-Source: APiQypJBR0VsXTUOks5yliB8aAc5q8D6l3Gg5z/mv3Da0c8XMYX7HdFCNrgqVwjEZd9i5aQQrfLYZw== X-Received: by 2002:adf:fa41:: with SMTP id y1mr17727689wrr.131.1588586862825; Mon, 04 May 2020 03:07:42 -0700 (PDT) Received: from x1w.redhat.com (26.red-88-21-207.staticip.rima-tde.net. [88.21.207.26]) by smtp.gmail.com with ESMTPSA id k9sm18517778wrd.17.2020.05.04.03.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 03:07:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 2/3] various: Remove unnecessary OBJECT() cast Date: Mon, 4 May 2020 12:07:34 +0200 Message-Id: <20200504100735.10269-3-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200504100735.10269-1-f4bug@amsat.org> References: <20200504100735.10269-1-f4bug@amsat.org> MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paul Durrant , Jason Wang , Mark Cave-Ayland , BALATON Zoltan , Gerd Hoffmann , "Edgar E. Iglesias" , Stefano Stabellini , qemu-block@nongnu.org, David Hildenbrand , Markus Armbruster , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Joel Stanley , Anthony Perard , xen-devel@lists.xenproject.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Corey Minyard , Richard Henderson , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Chubb , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , John Snow , David Gibson , Corey Minyard , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Andrew Jeffery , Cornelia Huck , Laurent Vivier , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The OBJECT() macro is defined as: #define OBJECT(obj) ((Object *)(obj)) which expands to: ((Object *)object_dynamic_cast_assert((Object *)(obj), (name), __FILE__, __LINE__, __func__)) This assertion can only fail when @obj points to something other than its stated type, i.e. when we're in undefined behavior country. Remove the unnecessary OBJECT() casts when we already know the pointer is of Object type. Patch created mechanically using spatch with this script: @@ typedef Object; Object *o; @@ - OBJECT(o) + o Acked-by: Cornelia Huck Acked-by: Corey Minyard Acked-by: John Snow Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- v2: Reword (Markus) --- hw/core/bus.c | 2 +- hw/ide/ahci-allwinner.c | 2 +- hw/ipmi/smbus_ipmi.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 8 ++++---- hw/s390x/sclp.c | 2 +- monitor/misc.c | 3 +-- qom/object.c | 4 ++-- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/hw/core/bus.c b/hw/core/bus.c index 3dc0a825f0..4ea5870de8 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -25,7 +25,7 @@ void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp) { - object_property_set_link(OBJECT(bus), OBJECT(handler), + object_property_set_link(OBJECT(bus), handler, QDEV_HOTPLUG_HANDLER_PROPERTY, errp); } diff --git a/hw/ide/ahci-allwinner.c b/hw/ide/ahci-allwinner.c index bb8393d2b6..8536b9eb5a 100644 --- a/hw/ide/ahci-allwinner.c +++ b/hw/ide/ahci-allwinner.c @@ -90,7 +90,7 @@ static void allwinner_ahci_init(Object *obj) SysbusAHCIState *s = SYSBUS_AHCI(obj); AllwinnerAHCIState *a = ALLWINNER_AHCI(obj); - memory_region_init_io(&a->mmio, OBJECT(obj), &allwinner_ahci_mem_ops, a, + memory_region_init_io(&a->mmio, obj, &allwinner_ahci_mem_ops, a, "allwinner-ahci", ALLWINNER_AHCI_MMIO_SIZE); memory_region_add_subregion(&s->ahci.mem, ALLWINNER_AHCI_MMIO_OFF, &a->mmio); diff --git a/hw/ipmi/smbus_ipmi.c b/hw/ipmi/smbus_ipmi.c index 2a9470d9df..f1a0148755 100644 --- a/hw/ipmi/smbus_ipmi.c +++ b/hw/ipmi/smbus_ipmi.c @@ -329,7 +329,7 @@ static void smbus_ipmi_init(Object *obj) { SMBusIPMIDevice *sid = SMBUS_IPMI(obj); - ipmi_bmc_find_and_link(OBJECT(obj), (Object **) &sid->bmc); + ipmi_bmc_find_and_link(obj, (Object **) &sid->bmc); } static void smbus_ipmi_get_fwinfo(struct IPMIInterface *ii, IPMIFwInfo *info) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index 0a2640c40b..52dcea9abd 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -150,9 +150,9 @@ petalogix_ml605_init(MachineState *machine) qdev_set_nic_properties(eth0, &nd_table[0]); qdev_prop_set_uint32(eth0, "rxmem", 0x1000); qdev_prop_set_uint32(eth0, "txmem", 0x1000); - object_property_set_link(OBJECT(eth0), OBJECT(ds), + object_property_set_link(OBJECT(eth0), ds, "axistream-connected", &error_abort); - object_property_set_link(OBJECT(eth0), OBJECT(cs), + object_property_set_link(OBJECT(eth0), cs, "axistream-control-connected", &error_abort); qdev_init_nofail(eth0); sysbus_mmio_map(SYS_BUS_DEVICE(eth0), 0, AXIENET_BASEADDR); @@ -163,9 +163,9 @@ petalogix_ml605_init(MachineState *machine) cs = object_property_get_link(OBJECT(eth0), "axistream-control-connected-target", NULL); qdev_prop_set_uint32(dma, "freqhz", 100 * 1000000); - object_property_set_link(OBJECT(dma), OBJECT(ds), + object_property_set_link(OBJECT(dma), ds, "axistream-connected", &error_abort); - object_property_set_link(OBJECT(dma), OBJECT(cs), + object_property_set_link(OBJECT(dma), cs, "axistream-control-connected", &error_abort); qdev_init_nofail(dma); sysbus_mmio_map(SYS_BUS_DEVICE(dma), 0, AXIDMA_BASEADDR); diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index ede056b3ef..4132286db7 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -322,7 +322,7 @@ void s390_sclp_init(void) object_property_add_child(qdev_get_machine(), TYPE_SCLP, new, NULL); - object_unref(OBJECT(new)); + object_unref(new); qdev_init_nofail(DEVICE(new)); } diff --git a/monitor/misc.c b/monitor/misc.c index 6c45fa490f..57af5fa5a4 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1839,8 +1839,7 @@ void object_add_completion(ReadLineState *rs, int nb_args, const char *str) static int qdev_add_hotpluggable_device(Object *obj, void *opaque) { GSList **list = opaque; - DeviceState *dev = (DeviceState *)object_dynamic_cast(OBJECT(obj), - TYPE_DEVICE); + DeviceState *dev = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE); if (dev == NULL) { return 0; diff --git a/qom/object.c b/qom/object.c index be700e831f..07c1443d0e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -762,7 +762,7 @@ Object *object_new_with_propv(const char *typename, } } - object_unref(OBJECT(obj)); + object_unref(obj); return obj; error: @@ -1687,7 +1687,7 @@ void object_property_add_child(Object *obj, const char *name, return; } - type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child))); + type = g_strdup_printf("child<%s>", object_get_typename(child)); op = object_property_add(obj, name, type, object_get_child_property, NULL, object_finalize_child_property, child, &local_err);