From 11bc30ffbe24d3d1be56d4f5c79e781026459be2 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Fri, 29 Nov 2019 14:54:23 +0100 Subject: [PATCH] Stop duplicating permset initialisation A permset can be initalised either via `__init__ ` or by getting `parent.permset` getter. The latter duplicates the logic in the former, which is not good as hacks into the internals of the permset. Remove the duplication by just calling explicitly permset(self) and returning the value of it. --- acl.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/acl.c b/acl.c index 3d0c0f6..b596f6d 100644 --- a/acl.c +++ b/acl.c @@ -952,23 +952,15 @@ static PyObject* Entry_get_parent(PyObject *obj, void* arg) { * should be created at init time! */ static PyObject* Entry_get_permset(PyObject *obj, void* arg) { - Entry_Object *self = (Entry_Object*)obj; PyObject *p; - Permset_Object *ps; - p = Permset_new(&Permset_Type, NULL, NULL); - if(p == NULL) - return NULL; - ps = (Permset_Object*)p; - if(acl_get_permset(self->entry, &ps->permset) == -1) { - PyErr_SetFromErrno(PyExc_IOError); - Py_DECREF(p); + PyObject *perm_arglist = Py_BuildValue("(O)", obj); + if (perm_arglist == NULL) { return NULL; } - ps->parent_entry = obj; - Py_INCREF(obj); - - return (PyObject*)p; + p = PyObject_CallObject((PyObject*)&Permset_Type, perm_arglist); + Py_DECREF(perm_arglist); + return p; } /* Sets the permset of the entry to the passed Permset */ -- 2.39.2