From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvquJ-0002aD-HD for qemu-devel@nongnu.org; Wed, 05 Apr 2017 15:47:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvquI-0007xx-Lu for qemu-devel@nongnu.org; Wed, 05 Apr 2017 15:47:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50852) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cvquI-0007xY-G6 for qemu-devel@nongnu.org; Wed, 05 Apr 2017 15:47:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81CB73D961 for ; Wed, 5 Apr 2017 19:47:53 +0000 (UTC) From: Eric Blake Date: Wed, 5 Apr 2017 14:47:32 -0500 Message-Id: <20170405194741.18956-5-eblake@redhat.com> In-Reply-To: <20170405194741.18956-1-eblake@redhat.com> References: <20170405194741.18956-1-eblake@redhat.com> Subject: [Qemu-devel] [PATCH v3 04/13] coccinelle: Add script to remove useless QObject casts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com We have macros in place to make it less verbose to add a subtype of QObject to both QDict and QList. While we have made cleanups like this in the past (see commit fcfcd8ffc, for example), having it be automated by Coccinelle makes it easier to maintain. The script is separate from the cleanups, for ease of review and backporting. A later patch will then add further possible cleanups. Signed-off-by: Eric Blake --- MAINTAINERS | 1 + scripts/coccinelle/qobject.cocci | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 scripts/coccinelle/qobject.cocci diff --git a/MAINTAINERS b/MAINTAINERS index c60235e..430efb0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1395,6 +1395,7 @@ S: Supported F: qobject/ F: include/qapi/qmp/ X: include/qapi/qmp/dispatch.h +F: scripts/coccinelle/qobject.cocci F: tests/check-qdict.c F: tests/check-qfloat.c F: tests/check-qint.c diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.cocci new file mode 100644 index 0000000..aa899e2 --- /dev/null +++ b/scripts/coccinelle/qobject.cocci @@ -0,0 +1,13 @@ +// Use QDict macros where they make sense +@@ +expression Obj, Key, E; +@@ +- qdict_put_obj(Obj, Key, QOBJECT(E)); ++ qdict_put(Obj, Key, E); + +// Use QList macros where they make sense +@@ +expression Obj, E; +@@ +- qlist_append_obj(Obj, QOBJECT(E)); ++ qlist_append(Obj, E); -- 2.9.3