diff --git a/setools/policyrep/bounds.pxi b/setools/policyrep/bounds.pxi index b7d1ee0..f94feaa 100644 --- a/setools/policyrep/bounds.pxi +++ b/setools/policyrep/bounds.pxi @@ -45,7 +45,7 @@ cdef class Bounds(PolicySymbol): b.policy = policy return b - def __init__(self, parent, child): + def __cinit__(self, parent, child): self.ruletype = BoundsRuletype.typebounds self.parent = parent self.child = child @@ -97,10 +97,11 @@ cdef class TypeboundsIterator(HashtabIterator): Type.factory(self.policy, datum)) def __len__(self): - cdef sepol.type_datum_t *datum - cdef sepol.hashtab_node_t *node - cdef uint32_t bucket = 0 - cdef size_t count = 0 + cdef: + sepol.type_datum_t *datum + sepol.hashtab_node_t *node + uint32_t bucket = 0 + size_t count = 0 while bucket < self.table[0].size: node = self.table[0].htable[bucket] diff --git a/setools/policyrep/mlsrule.pxi b/setools/policyrep/mlsrule.pxi index 7e0bfd3..dfaecfd 100644 --- a/setools/policyrep/mlsrule.pxi +++ b/setools/policyrep/mlsrule.pxi @@ -44,7 +44,7 @@ cdef class MLSRule(PolicyRule): r.handle = symbol return r - def __init__(self, rng): + def __cinit__(self, rng): self.ruletype = MLSRuletype.range_transition self.rng = rng diff --git a/setools/policyrep/rbacrule.pxi b/setools/policyrep/rbacrule.pxi index ce5b214..38be5b9 100644 --- a/setools/policyrep/rbacrule.pxi +++ b/setools/policyrep/rbacrule.pxi @@ -45,7 +45,7 @@ cdef class RoleAllow(PolicyRule): r.handle = symbol return r - def __init__(self): + def __cinit__(self): self.ruletype = RBACRuletype.allow def __str__(self): @@ -106,7 +106,7 @@ cdef class RoleTransition(PolicyRule): r.handle = symbol return r - def __init__(self): + def __cinit__(self): self.ruletype = RBACRuletype.role_transition def __str__(self): diff --git a/setools/policyrep/rule.pxi b/setools/policyrep/rule.pxi index 31594bc..1ab308e 100644 --- a/setools/policyrep/rule.pxi +++ b/setools/policyrep/rule.pxi @@ -22,11 +22,9 @@ cdef class PolicyRule(PolicySymbol): """This is base class for policy rules.""" + # This is initialized to False cdef readonly bint extended - def __init__(self): - self.extended = False - def __str__(self): raise NotImplementedError diff --git a/setools/policyrep/symbol.pxi b/setools/policyrep/symbol.pxi index 956efd7..6d4d867 100644 --- a/setools/policyrep/symbol.pxi +++ b/setools/policyrep/symbol.pxi @@ -25,8 +25,7 @@ cdef class PolicySymbol: """This is a base class for all policy objects.""" - cdef: - readonly SELinuxPolicy policy + cdef readonly SELinuxPolicy policy def __hash__(self): return hash(str(self)) @@ -145,6 +144,7 @@ cdef class EbitmapIterator(PolicyIterator): cdef: sepol.ebitmap_node_t *node size_t curr + size_t count = 0 count = 0 curr = sepol.ebitmap_start(self.bmap, &node) @@ -184,7 +184,7 @@ cdef class HashtabIterator(PolicyIterator): sepol.hashtab_node_t *curr unsigned int bucket - def _next_bucket(self): + cdef void _next_bucket(self): """Internal method for advancing to the next bucket.""" self.bucket += 1 if self.bucket < self.table[0].size: @@ -192,7 +192,7 @@ cdef class HashtabIterator(PolicyIterator): else: self.node = NULL - def _next_node(self): + cdef void _next_node(self): """Internal method for advancing to the next node.""" if self.node != NULL and self.node.next != NULL: self.node = self.node.next diff --git a/setools/policyrep/terule.pxi b/setools/policyrep/terule.pxi index fea0f39..1bab3a4 100644 --- a/setools/policyrep/terule.pxi +++ b/setools/policyrep/terule.pxi @@ -282,7 +282,7 @@ cdef class AVRuleXperm(AVRule): r._conditional_block = conditional_block return r - def __init__(self): + def __cinit__(self): self.extended = True def __str__(self): @@ -481,7 +481,7 @@ cdef class FileNameTERule(PolicyRule): r.datum = datum return r - def __init__(self): + def __cinit__(self): self.ruletype = TERuletype.type_transition def __str__(self):