|
|
71cd55 |
From f043078f1debeb1c84d4f6943aa689c33dd9cefc Mon Sep 17 00:00:00 2001
|
|
|
71cd55 |
From: James Carter <jwcart2@gmail.com>
|
|
|
71cd55 |
Date: Tue, 30 Mar 2021 13:39:13 -0400
|
|
|
71cd55 |
Subject: [PATCH] libsepol/cil: Cleanup build AST helper functions
|
|
|
71cd55 |
|
|
|
71cd55 |
Since parse_current, finished, and extra_args can never be NULL,
|
|
|
71cd55 |
remove the useless check and directly assign local variables from
|
|
|
71cd55 |
extra_args.
|
|
|
71cd55 |
|
|
|
71cd55 |
Signed-off-by: James Carter <jwcart2@gmail.com>
|
|
|
71cd55 |
---
|
|
|
71cd55 |
libsepol/cil/src/cil_build_ast.c | 44 ++++++++------------------------
|
|
|
71cd55 |
1 file changed, 10 insertions(+), 34 deletions(-)
|
|
|
71cd55 |
|
|
|
71cd55 |
diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
|
|
|
71cd55 |
index eee21086bba8..0d6d91a7dc34 100644
|
|
|
71cd55 |
--- a/libsepol/cil/src/cil_build_ast.c
|
|
|
71cd55 |
+++ b/libsepol/cil/src/cil_build_ast.c
|
|
|
71cd55 |
@@ -6065,28 +6065,16 @@ void cil_destroy_src_info(struct cil_src_info *info)
|
|
|
71cd55 |
|
|
|
71cd55 |
int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *finished, void *extra_args)
|
|
|
71cd55 |
{
|
|
|
71cd55 |
- struct cil_args_build *args = NULL;
|
|
|
71cd55 |
- struct cil_tree_node *ast_current = NULL;
|
|
|
71cd55 |
- struct cil_db *db = NULL;
|
|
|
71cd55 |
+ struct cil_args_build *args = extra_args;
|
|
|
71cd55 |
+ struct cil_db *db = args->db;
|
|
|
71cd55 |
+ struct cil_tree_node *ast_current = args->ast;
|
|
|
71cd55 |
+ struct cil_tree_node *tunif = args->tunif;
|
|
|
71cd55 |
+ struct cil_tree_node *in = args->in;
|
|
|
71cd55 |
+ struct cil_tree_node *macro = args->macro;
|
|
|
71cd55 |
+ struct cil_tree_node *boolif = args->boolif;
|
|
|
71cd55 |
struct cil_tree_node *ast_node = NULL;
|
|
|
71cd55 |
- struct cil_tree_node *tunif = NULL;
|
|
|
71cd55 |
- struct cil_tree_node *in = NULL;
|
|
|
71cd55 |
- struct cil_tree_node *macro = NULL;
|
|
|
71cd55 |
- struct cil_tree_node *boolif = NULL;
|
|
|
71cd55 |
int rc = SEPOL_ERR;
|
|
|
71cd55 |
|
|
|
71cd55 |
- if (parse_current == NULL || finished == NULL || extra_args == NULL) {
|
|
|
71cd55 |
- goto exit;
|
|
|
71cd55 |
- }
|
|
|
71cd55 |
-
|
|
|
71cd55 |
- args = extra_args;
|
|
|
71cd55 |
- ast_current = args->ast;
|
|
|
71cd55 |
- db = args->db;
|
|
|
71cd55 |
- tunif = args->tunif;
|
|
|
71cd55 |
- in = args->in;
|
|
|
71cd55 |
- macro = args->macro;
|
|
|
71cd55 |
- boolif = args->boolif;
|
|
|
71cd55 |
-
|
|
|
71cd55 |
if (parse_current->parent->cl_head != parse_current) {
|
|
|
71cd55 |
/* ignore anything that isn't following a parenthesis */
|
|
|
71cd55 |
rc = SEPOL_OK;
|
|
|
71cd55 |
@@ -6474,20 +6462,11 @@ exit:
|
|
|
71cd55 |
|
|
|
71cd55 |
int __cil_build_ast_last_child_helper(struct cil_tree_node *parse_current, void *extra_args)
|
|
|
71cd55 |
{
|
|
|
71cd55 |
- int rc = SEPOL_ERR;
|
|
|
71cd55 |
- struct cil_tree_node *ast = NULL;
|
|
|
71cd55 |
- struct cil_args_build *args = NULL;
|
|
|
71cd55 |
-
|
|
|
71cd55 |
- if (extra_args == NULL) {
|
|
|
71cd55 |
- goto exit;
|
|
|
71cd55 |
- }
|
|
|
71cd55 |
-
|
|
|
71cd55 |
- args = extra_args;
|
|
|
71cd55 |
- ast = args->ast;
|
|
|
71cd55 |
+ struct cil_args_build *args = extra_args;
|
|
|
71cd55 |
+ struct cil_tree_node *ast = args->ast;
|
|
|
71cd55 |
|
|
|
71cd55 |
if (ast->flavor == CIL_ROOT) {
|
|
|
71cd55 |
- rc = SEPOL_OK;
|
|
|
71cd55 |
- goto exit;
|
|
|
71cd55 |
+ return SEPOL_OK;
|
|
|
71cd55 |
}
|
|
|
71cd55 |
|
|
|
71cd55 |
args->ast = ast->parent;
|
|
|
71cd55 |
@@ -6516,9 +6495,6 @@ int __cil_build_ast_last_child_helper(struct cil_tree_node *parse_current, void
|
|
|
71cd55 |
cil_tree_children_destroy(parse_current->parent);
|
|
|
71cd55 |
|
|
|
71cd55 |
return SEPOL_OK;
|
|
|
71cd55 |
-
|
|
|
71cd55 |
-exit:
|
|
|
71cd55 |
- return rc;
|
|
|
71cd55 |
}
|
|
|
71cd55 |
|
|
|
71cd55 |
int cil_build_ast(struct cil_db *db, struct cil_tree_node *parse_tree, struct cil_tree_node *ast)
|
|
|
71cd55 |
--
|
|
|
71cd55 |
2.32.0
|
|
|
71cd55 |
|