From patchwork Tue Dec 1 20:38:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Lawrence X-Patchwork-Id: 7740891 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7BA8BEEE1 for ; Tue, 1 Dec 2015 20:44:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC7D220692 for ; Tue, 1 Dec 2015 20:44:47 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (emvm-gh1-uea09.nsa.gov [63.239.67.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2EAF20686 for ; Tue, 1 Dec 2015 20:44:46 +0000 (UTC) X-TM-IMSS-Message-ID: <1f3d6ab7000036e1@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1) id 1f3d6ab7000036e1 ; Tue, 1 Dec 2015 15:44:58 -0500 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id tB1Kh2oK027469; Tue, 1 Dec 2015 15:43:03 -0500 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id tB1KeHGU144988 for ; Tue, 1 Dec 2015 15:40:17 -0500 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id tB1KeDY4027265 for ; Tue, 1 Dec 2015 15:40:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BiAAAyAl5WhKu/HtheGQEBAg8BAQEBhE2uWo1GhAQKF4gVAQEBAQEBEgEBAQoWhQwsgQWBCxOIGQMSnROhDoZUh1GEaAxBgTEFjhiIP4tCgXaObEWFWYdXgnQWB4F0IDSFcQEBAQ X-IPAS-Result: A1BiAAAyAl5WhKu/HtheGQEBAg8BAQEBhE2uWo1GhAQKF4gVAQEBAQEBEgEBAQoWhQwsgQWBCxOIGQMSnROhDoZUh1GEaAxBgTEFjhiIP4tCgXaObEWFWYdXgnQWB4F0IDSFcQEBAQ X-IronPort-AV: E=Sophos;i="5.20,370,1444708800"; d="scan'208";a="4982889" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 01 Dec 2015 15:40:08 -0500 X-TM-IMSS-Message-ID: <1f40f03b000089d1@nsa.gov> Received: from exchange10.columbia.tresys.com (exchange10.columbia.tresys.com [216.30.191.171]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES256-SHA (256/256)) id 1f40f03b000089d1 ; Tue, 1 Dec 2015 15:40:19 -0500 Received: from amos.columbia.tresys.com (10.1.12.120) by Exchange10.columbia.tresys.com (192.168.243.126) with Microsoft SMTP Server (TLS) id 14.1.438.0; Tue, 1 Dec 2015 15:38:49 -0500 From: Steve Lawrence To: SELinux List Subject: [PATCH] libsepol/cil: Remove duplicated 'if' condition in cil_tree Date: Tue, 1 Dec 2015 15:38:47 -0500 Message-ID: <1449002327-32333-1-git-send-email-slawrence@tresys.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 X-TM-AS-MML: disable X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP David Binderman wrote: > 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); > } > > Two mentions of filecon->context_str. Suggest code rework. Reported-by: David Binderman Signed-off-by: Steve Lawrence --- libsepol/cil/src/cil_tree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libsepol/cil/src/cil_tree.c b/libsepol/cil/src/cil_tree.c index f641baa..8357a32 100644 --- a/libsepol/cil/src/cil_tree.c +++ b/libsepol/cil/src/cil_tree.c @@ -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);