Blame SOURCES/0010-libsepol-cil-Cleanup-build-AST-helper-functions.patch

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