From 0c8981f035098f92ad04be00969406d9c3fc5934 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 23 Feb 2017 11:48:24 +0100 Subject: [PATCH] python: initialize specific fields of PyTypeObject MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Acked-by: Wei Liu --- 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 5d21c38879..ddd18d44ef 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 74a80cade7..66ab08d4e6 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 } }; -- 2.30.2