On Sat, Jun 26, 2021 at 2:33 PM Nicolas Iooss <nicolas.iooss@xxxxxxx> wrote: > > On Thu, Jun 24, 2021 at 9:58 PM James Carter <jwcart2@xxxxxxxxx> wrote: > > > > Create the function cil_tree_subtree_has_decl() that returns CIL_TRUE > > if the subtree has a declaration in it and CIL_FALSE otherwise. > > > > Signed-off-by: James Carter <jwcart2@xxxxxxxxx> > > For these 2 patches: > > Acked-by: Nicolas Iooss <nicolas.iooss@xxxxxxx> I applied them. Thanks! Nicolas > > --- > > libsepol/cil/src/cil_tree.c | 16 ++++++++++++++++ > > libsepol/cil/src/cil_tree.h | 2 ++ > > 2 files changed, 18 insertions(+) > > > > diff --git a/libsepol/cil/src/cil_tree.c b/libsepol/cil/src/cil_tree.c > > index 067268eb..4cf8dcc8 100644 > > --- a/libsepol/cil/src/cil_tree.c > > +++ b/libsepol/cil/src/cil_tree.c > > @@ -136,6 +136,22 @@ __attribute__((format (printf, 3, 4))) void cil_tree_log(struct cil_tree_node *n > > cil_log(lvl,"\n"); > > } > > > > +int cil_tree_subtree_has_decl(struct cil_tree_node *node) > > +{ > > + while (node) { > > + if (node->flavor >= CIL_MIN_DECLARATIVE) { > > + return CIL_TRUE; > > + } > > + if (node->cl_head != NULL) { > > + if (cil_tree_subtree_has_decl(node->cl_head)) > > + return CIL_TRUE; > > + } > > + node = node->next; > > + } > > + > > + return CIL_FALSE; > > +} > > + > > int cil_tree_init(struct cil_tree **tree) > > { > > struct cil_tree *new_tree = cil_malloc(sizeof(*new_tree)); > > diff --git a/libsepol/cil/src/cil_tree.h b/libsepol/cil/src/cil_tree.h > > index bac9f1e4..f4d22071 100644 > > --- a/libsepol/cil/src/cil_tree.h > > +++ b/libsepol/cil/src/cil_tree.h > > @@ -54,6 +54,8 @@ struct cil_tree_node *cil_tree_get_next_path(struct cil_tree_node *node, char ** > > char *cil_tree_get_cil_path(struct cil_tree_node *node); > > __attribute__((format (printf, 3, 4))) void cil_tree_log(struct cil_tree_node *node, enum cil_log_level lvl, const char* msg, ...); > > > > +int cil_tree_subtree_has_decl(struct cil_tree_node *node); > > + > > int cil_tree_init(struct cil_tree **tree); > > void cil_tree_destroy(struct cil_tree **tree); > > void cil_tree_subtree_destroy(struct cil_tree_node *node); > > -- > > 2.26.3 > >