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=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no 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 DB271C47257 for ; Fri, 8 May 2020 12:47:35 +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 AE40424969 for ; Fri, 8 May 2020 12:47:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ai7F2GO2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE40424969 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 1jX2PV-00037r-Hk; Fri, 08 May 2020 12:47:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jX2PT-00037l-EX for xen-devel@lists.xenproject.org; Fri, 08 May 2020 12:47:23 +0000 X-Inumbo-ID: 0fe4b810-912a-11ea-ae69-bc764e2007e4 Received: from us-smtp-delivery-1.mimecast.com (unknown [207.211.31.81]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 0fe4b810-912a-11ea-ae69-bc764e2007e4; Fri, 08 May 2020 12:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588942042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fsnozb6kIQGYwomOyBKftMgcGklRNkmQU34LmQ0rQgU=; b=ai7F2GO2OT2lWJ7rMgsugh4SNiaiYrGBG4mwVEVXpm/Mf375CDa//61e6Hvc1/xmWxGm+S Y82K/K5Ey7tSgsVaQQnVoQiqRodbSSUndbnypRNUmbAv80G5OuVa/GZYSaGPZRKp+BWYxs S0NWMkJ2LNvt/6Q+am+8cdkqo7UhMmU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-xHC9BoC8MPSLoyVaICWZKA-1; Fri, 08 May 2020 08:47:17 -0400 X-MC-Unique: xHC9BoC8MPSLoyVaICWZKA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 541CB107ACF2; Fri, 8 May 2020 12:47:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60BF76ACF1; Fri, 8 May 2020 12:47:06 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D67E811358BC; Fri, 8 May 2020 14:47:04 +0200 (CEST) From: Markus Armbruster To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: Re: [PATCH v2 3/3] hw: Remove unnecessary DEVICE() cast References: <20200504100735.10269-1-f4bug@amsat.org> <20200504100735.10269-4-f4bug@amsat.org> Date: Fri, 08 May 2020 14:47:04 +0200 In-Reply-To: <20200504100735.10269-4-f4bug@amsat.org> ("Philippe =?utf-8?Q?Mathieu-Daud=C3=A9=22's?= message of "Mon, 4 May 2020 12:07:35 +0200") Message-ID: <87r1vuy4on.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 , qemu-devel@nongnu.org, Gerd Hoffmann , "Edgar E. Iglesias" , Stefano Stabellini , qemu-block@nongnu.org, David Hildenbrand , Halil Pasic , Christian Borntraeger , Aleksandar Markovic , Joel Stanley , Anthony Perard , xen-devel@lists.xenproject.org, David Gibson , Philippe =?utf-8?Q?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=C3=A9dric?= Le Goater , John Snow , Richard Henderson , "Daniel P. =?utf-8?Q?Berrang=C3=A9?=" , Andrew Jeffery , Cornelia Huck , Laurent Vivier , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Philippe Mathieu-Daud=C3=A9 writes: > The DEVICE() macro is defined as: > > #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE) > > which expands to: > > ((DeviceState *)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 DEVICE() casts when we already know the > pointer is of DeviceState type. > > Patch created mechanically using spatch with this script: > > @@ > typedef DeviceState; > DeviceState *s; > @@ > - DEVICE(s) > + s > > Acked-by: David Gibson > Acked-by: Paul Durrant > Reviewed-by: Markus Armbruster > Reviewed-by: C=C3=A9dric Le Goater > Acked-by: John Snow > Reviewed-by: Richard Henderson > Signed-off-by: Philippe Mathieu-Daud=C3=A9 Lovely. Reviewed-by: Markus Armbruster Now repeat this exercise for each QOM type cast macro :)