From patchwork Thu Feb 23 10:48:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 9588157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4E8A86057F for ; Thu, 23 Feb 2017 10:51:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B38428610 for ; Thu, 23 Feb 2017 10:51:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FECF28695; Thu, 23 Feb 2017 10:51:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0DC228610 for ; Thu, 23 Feb 2017 10:51:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgqxD-0005r7-Rr; Thu, 23 Feb 2017 10:48:55 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgqxC-0005qJ-OB for xen-devel@lists.xen.org; Thu, 23 Feb 2017 10:48:54 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 58/49-24539-61EBEA85; Thu, 23 Feb 2017 10:48:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRWlGSWpSXmKPExsXilM8ioyu6b12 EwdoZ8hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a0a53MBSf0KrYcusrUwLhToouRk0NIYBWj xMQNPhB2tsTkf59Yuhi5OFgELjFLPO8/yw6SkBDwlDi5ooUFwnaWePZgHztIkZDAIUaJe8tOs IEk2ARCJdq3z2AFsUUEpCWufb7MCFLELDCXUeLzv21gk4QF3CUe/ZvFDGKzCKhKfF1+G2wqr4 C/xMXGfkaIDXISN891gtVwCgRIvOxrY4U4z19i4tRZjBD1ghInZz4B6uUAWqAusX6eEEiYX0B JYtv6y2AlzALyEs1bZzNPYBSehaRjFkLHLCRVCxiZVzGqF6cWlaUW6ZrrJRVlpmeU5CZm5uga Gpjp5aYWFyemp+YkJhXrJefnbmIEBjkDEOxgnHnZ/xCjJAeTkiivz551EUJ8SfkplRmJxRnxR aU5qcWHGGU4OJQkeJ+C5ASLUtNTK9Iyc4DxBpOW4OBREuHtBUnzFhck5hZnpkOkTjEac8yZvf sNE8e8FwfeMAmx5OXnpUqJ834FKRUAKc0ozYMbBEsDlxhlpYR5GYFOE+IpSC3KzSxBlX/FKM7 BqCTMK7gXaApPZl4J3L5XQKcwAZ1i6bwW5JSSRISUVAOjtMVNoxcrVIy+ekq/DtVlS4iYfG12 +n3mk0t2J6vu1bYo+lLAev2414xX04LLNno0XGE8VXa/dKL7j2ksHbV2Z0L+fDq4tmX6v6cC9 UmbAuxsfqx/u/OUjNdXw6BwK7WdX/WMWBqu6HCvOZNX+5Znw4dj3E//ejZ/e7VYbds3seTcHR KSDW90lViKMxINtZiLihMBWGYiwP4CAAA= X-Env-Sender: marmarek@invisiblethingslab.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1487846932!51146663!1 X-Originating-IP: [66.111.4.28] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13912 invoked from network); 23 Feb 2017 10:48:53 -0000 Received: from out4-smtp.messagingengine.com (HELO out4-smtp.messagingengine.com) (66.111.4.28) by server-5.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 23 Feb 2017 10:48:53 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 83ED4209FE; Thu, 23 Feb 2017 05:48:52 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Thu, 23 Feb 2017 05:48:52 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=VPVwoL8e8UYHK5h51ouR3Nwa/gA=; b=JiFRTfZwhfwBIAYq9mPf z0zXiu059cgNKyUxI1mR+Eny2ADz5YkR23QkDqr3o08zH4LgKnWKlRcHS7OC7QeC 5R9Kj6XO1JIPKimKfQeW8MXTJNVwzrGuN/EAHX+ukzDQQvnZYSY/YrJwlj9Jy8pj Iyta4vdPAtf4fMWn/KdUdvE= X-ME-Sender: X-Sasl-enc: shiGTMHIQLYCBFVZfwSxgb8oWc6HtFwr5g0pgUJ72njm 1487846932 Received: from devel-3rdparty.localdomain (89-70-103-23.dynamic.chello.pl [89.70.103.23]) by mail.messagingengine.com (Postfix) with ESMTPA id 8C26924357; Thu, 23 Feb 2017 05:48:51 -0500 (EST) From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xen.org Date: Thu, 23 Feb 2017 11:48:24 +0100 Message-Id: <1487846908-21462-5-git-send-email-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487846908-21462-1-git-send-email-marmarek@invisiblethingslab.com> References: <1487846908-21462-1-git-send-email-marmarek@invisiblethingslab.com> MIME-Version: 1.0 Organization: Invisible Things Lab Cc: Wei Liu , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [Xen-devel] [PATCH 4/8] python: initialize specific fields of PyTypeObject X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fields not named here will be zero-initialized anyway, but using this way will be much easier to support both Python2 and Python3. Signed-off-by: Marek Marczykowski-Górecki --- tools/python/xen/lowlevel/xc/xc.c | 47 ++++++++------------------------------- tools/python/xen/lowlevel/xs/xs.c | 47 ++++++++------------------------------- 2 files changed, 18 insertions(+), 76 deletions(-) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 75842ef..bcbb7b0 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -2675,44 +2675,15 @@ static void PyXc_dealloc(XcObject *self) static PyTypeObject PyXcType = { PyObject_HEAD_INIT(NULL) - 0, - PKG "." CLS, - sizeof(XcObject), - 0, - (destructor)PyXc_dealloc, /* tp_dealloc */ - NULL, /* tp_print */ - NULL, /* tp_getattr */ - NULL, /* tp_setattr */ - NULL, /* tp_compare */ - NULL, /* tp_repr */ - NULL, /* tp_as_number */ - NULL, /* tp_as_sequence */ - NULL, /* tp_as_mapping */ - NULL, /* tp_hash */ - NULL, /* tp_call */ - NULL, /* tp_str */ - NULL, /* tp_getattro */ - NULL, /* tp_setattro */ - NULL, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Xen client connections", /* tp_doc */ - NULL, /* tp_traverse */ - NULL, /* tp_clear */ - NULL, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - NULL, /* tp_iter */ - NULL, /* tp_iternext */ - pyxc_methods, /* tp_methods */ - NULL, /* tp_members */ - NULL, /* tp_getset */ - NULL, /* tp_base */ - NULL, /* tp_dict */ - NULL, /* tp_descr_get */ - NULL, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PyXc_init, /* tp_init */ - NULL, /* tp_alloc */ - PyXc_new, /* tp_new */ + .tp_name = PKG "." CLS, + .tp_basicsize = sizeof(XcObject), + .tp_itemsize = 0, + .tp_dealloc = (destructor)PyXc_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_doc = "Xen client connections", + .tp_methods = pyxc_methods, + .tp_init = (initproc)PyXc_init, + .tp_new = PyXc_new, }; static PyMethodDef xc_methods[] = { { NULL } }; diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c index 74a80ca..66ab08d 100644 --- a/tools/python/xen/lowlevel/xs/xs.c +++ b/tools/python/xen/lowlevel/xs/xs.c @@ -927,44 +927,15 @@ static void xshandle_dealloc(XsHandle *self) static PyTypeObject xshandle_type = { PyObject_HEAD_INIT(NULL) - 0, - PKG "." CLS, - sizeof(XsHandle), - 0, - (destructor)xshandle_dealloc, /* tp_dealloc */ - NULL, /* tp_print */ - NULL, /* tp_getattr */ - NULL, /* tp_setattr */ - NULL, /* tp_compare */ - NULL, /* tp_repr */ - NULL, /* tp_as_number */ - NULL, /* tp_as_sequence */ - NULL, /* tp_as_mapping */ - NULL, /* tp_hash */ - NULL, /* tp_call */ - NULL, /* tp_str */ - NULL, /* tp_getattro */ - NULL, /* tp_setattro */ - NULL, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Xenstore connections", /* tp_doc */ - NULL, /* tp_traverse */ - NULL, /* tp_clear */ - NULL, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - NULL, /* tp_iter */ - NULL, /* tp_iternext */ - xshandle_methods, /* tp_methods */ - NULL, /* tp_members */ - NULL, /* tp_getset */ - NULL, /* tp_base */ - NULL, /* tp_dict */ - NULL, /* tp_descr_get */ - NULL, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)xshandle_init, /* tp_init */ - NULL, /* tp_alloc */ - xshandle_new, /* tp_new */ + .tp_name = PKG "." CLS, + .tp_basicsize = sizeof(XsHandle), + .tp_itemsize = 0, + .tp_dealloc = (destructor)xshandle_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_doc = "Xenstore connections", + .tp_methods = xshandle_methods, + .tp_init = (initproc)xshandle_init, + .tp_new = xshandle_new, }; static PyMethodDef xs_methods[] = { { NULL } };