Skip to contentSkip to conversation

libsepol/cil: Remove duplicated 'if' condition in cil_tree

PATCH New Steve Lawrence 1 participant 1 message Dec 1, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol/cil: Remove duplicated 'if' condition in cil_tree

Quoted 14 lines · David Binderman

Hello there,

./cil/src/cil_tree.c:1279:36: warning: duplicated 'if' condition [-Wduplicated-cond]

Source code is

            if (filecon->context_str != NULL) {
                cil_log(CIL_INFO, " %s", filecon->context_str);
            } else if (filecon->context != NULL) {
                cil_tree_print_context(filecon->context);
            } else if (filecon->context_str != NULL) {
                cil_log(CIL_INFO, " %s", filecon->context_str);
            }
Quoted 1 line

Two mentions of filecon->context_str. Suggest code rework.

---
 libsepol/cil/src/cil_tree.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
libsepol/cil/src/cil_tree.c +1 -3
index f641baa..8357a32 100644
@@ -1302,9 +1302,7 @@ void cil_tree_print_node(struct cil_tree_node *node)
 			cil_log(CIL_INFO, "FILECON:");
 			cil_log(CIL_INFO, " %s %d", filecon->path_str, filecon->type);
 
-			if (filecon->context_str != NULL) {
-				cil_log(CIL_INFO, " %s", filecon->context_str);
-			} else if (filecon->context != NULL) {
+			if (filecon->context != NULL) {
 				cil_tree_print_context(filecon->context);
 			} else if (filecon->context_str != NULL) {
 				cil_log(CIL_INFO, " %s", filecon->context_str);
Signature · 1 line
2.4.3