From patchwork Sun Sep 25 12:16:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 9349693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A3FF3607F0 for ; Sun, 25 Sep 2016 12:17:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9392328A18 for ; Sun, 25 Sep 2016 12:17:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8544828D47; Sun, 25 Sep 2016 12:17:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (emsm-gh1-uea11.nsa.gov [8.44.101.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 748F028A18 for ; Sun, 25 Sep 2016 12:17:56 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.30,393,1470700800"; d="scan'208";a="19528969" IronPort-PHdr: =?us-ascii?q?9a23=3AUMzdeRQr2J9J2uaxw8NkWyOXT9psv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa64YRWN2/xhgRfzUJnB7Loc0qyN4vqmADVLvszJmUtBWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4?= =?us-ascii?q?Ov7yUtaLyZ/mjabrotaMOU1hv3mUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO?= =?us-ascii?q?9MxGlldhq5lhf44dqsrtY4q3wD888784Z8dYmyP+FhFf0LRAghZns44MztqAnr?= =?us-ascii?q?URqE5nxaVH4f1BVPHVvr9hb/C7HwuSz+v/E1+S6dJta+GbY1UjOm5rwtSRjvkz?= =?us-ascii?q?wvMmIptmbNhZoj3+pgvBu9qkknkMbva4aPOa87J/vQ?= X-IPAS-Result: =?us-ascii?q?A2FEBQARwOdX/wHyM5BdSBgNgn4BAQEBAR6BU7p9IIYjgR5?= =?us-ascii?q?MAQEBAQEBAQECAQJbJ4IyBAMTBYIYAiARGiAOAwkCFw0CIgQCAgIBAS0VAR4LB?= =?us-ascii?q?RgEiCoEAbEBhVGHIYEGhTGIahEBgyCCWgWZdoFljXmKB4VukGdUhQdwhFMNFwd?= =?us-ascii?q?agScBAQE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 25 Sep 2016 12:17:21 +0000 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 u8PCGfgE015444; Sun, 25 Sep 2016 08:16:49 -0400 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 u8PCGdHN238090 for ; Sun, 25 Sep 2016 08:16:39 -0400 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 u8PCGdhN015441 for ; Sun, 25 Sep 2016 08:16:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CRAQCdv+dXhyIeaIFdHgYMgzsBAQEBAYFxpS6RQ4Qnh0ZMAQIBAQEBAQITAQEBCgsJCRmFOg8BewImAnKISwQBoR+PZoVRhyGBBoUxiWSCOIJaBZl2gWWNeY91kGeDHQELAYIxcIRTK4IBAQEB X-IPAS-Result: A1CRAQCdv+dXhyIeaIFdHgYMgzsBAQEBAYFxpS6RQ4Qnh0ZMAQIBAQEBAQITAQEBCgsJCRmFOg8BewImAnKISwQBoR+PZoVRhyGBBoUxiWSCOIJaBZl2gWWNeY91kGeDHQELAYIxcIRTK4IBAQEB X-IronPort-AV: E=Sophos;i="5.30,393,1470715200"; d="scan'208";a="5727347" Received: from emsm-gh1-uea10.corp.nsa.gov (HELO emsm-gh1-uea10.nsa.gov) ([10.208.41.36]) by goalie.tycho.ncsc.mil with ESMTP; 25 Sep 2016 08:16:38 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3ARi3OuRUVJcxtWvJKvuFImXjtxJDV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYZheBt8tkgFKBZ4jH8fUM07OQ6PG6HzVZqsnb+Fk5M7V0Hycfjs?= =?us-ascii?q?sXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJP?= =?us-ascii?q?K/jvHcaK1oLshrr0osSYPF8ArQH+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf?= =?us-ascii?q?9d32JiKAHbtR/94sCt4MwrqHwI6Lpyv/JHBL73e6U+UKxwECUtM2dz4tbi8xbE?= =?us-ascii?q?U1ih/HwZB0MXmR1MChONzRb9RYy55i37ve150TLcPMrxVqscXGiyqaBxR0m722?= =?us-ascii?q?88Kzcl/TSP2YRLh6VBrUf5qg=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0HDAQCdv+dXhyIeaIFdSAEXAQYBBQGCf?= =?us-ascii?q?QEBAQEBgXGlLpFDhCeHRkwBAQEBAQEBAQIBAhABAQEKCwkJGS+CMhiCQQ8BewI?= =?us-ascii?q?mAnKISwQBoR+PZoVRhyGBBoUxiWSCOIJaBZl2gWWNeY91kGeDHQELAYIxcIRTK?= =?us-ascii?q?4IBAQEB?= X-IPAS-Result: =?us-ascii?q?A0HDAQCdv+dXhyIeaIFdSAEXAQYBBQGCfQEBAQEBgXGlLpF?= =?us-ascii?q?DhCeHRkwBAQEBAQEBAQIBAhABAQEKCwkJGS+CMhiCQQ8BewImAnKISwQBoR+PZ?= =?us-ascii?q?oVRhyGBBoUxiWSCOIJaBZl2gWWNeY91kGeDHQELAYIxcIRTK4IBAQEB?= X-IronPort-AV: E=Sophos;i="5.30,393,1470700800"; d="scan'208";a="17941982" Received: from mx1.polytechnique.org ([129.104.30.34]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2016 12:16:37 +0000 Received: from localhost.localdomain (32.206.133.77.rev.sfr.net [77.133.206.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 91FFF564E1C for ; Sun, 25 Sep 2016 14:16:34 +0200 (CEST) From: Nicolas Iooss To: selinux@tycho.nsa.gov Subject: [PATCH 1/3] libselinux: silent -Wsign-compare warnings Date: Sun, 25 Sep 2016 14:16:07 +0200 Message-Id: <20160925121609.14516-1-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.10.0 MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sun Sep 25 14:16:35 2016 +0200 (CEST)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org 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-Virus-Scanned: ClamAV using ClamSMTP When building libselinux with gcc and many warning flags, the build fails with the following errors: selinux_restorecon.c: In function ‘selinux_restorecon’: selinux_restorecon.c:784:36: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] if (!flags.ignore_digest && size == fc_digest_len && ^~ selabel_digest.c: In function ‘main’: selabel_digest.c:162:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] for (i = 0; i < digest_len; i++) ^ selabel_digest.c:173:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] for (i = 0; i < num_specfiles; i++) { ^ clang reports the precise type information of the variables: selinux_restorecon.c:784:36: error: comparison of integers of different signs: 'ssize_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] if (!flags.ignore_digest && size == fc_digest_len && ~~~~ ^ ~~~~~~~~~~~~~ selabel_digest.c:162:16: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] for (i = 0; i < digest_len; i++) ~ ^ ~~~~~~~~~~ selabel_digest.c:173:17: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] for (i = 0; i < num_specfiles; i++) { ~ ^ ~~~~~~~~~~~~~ Silent the warnings by using size_t where appropriate. Signed-off-by: Nicolas Iooss --- libselinux/src/selinux_restorecon.c | 2 +- libselinux/utils/selabel_digest.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c index d49fb15f836e..0d3e4d585151 100644 --- a/libselinux/src/selinux_restorecon.c +++ b/libselinux/src/selinux_restorecon.c @@ -781,7 +781,7 @@ int selinux_restorecon(const char *pathname_orig, size = getxattr(pathname, RESTORECON_LAST, xattr_value, fc_digest_len); - if (!flags.ignore_digest && size == fc_digest_len && + if (!flags.ignore_digest && (size_t)size == fc_digest_len && memcmp(fc_digest, xattr_value, fc_digest_len) == 0) { selinux_log(SELINUX_INFO, diff --git a/libselinux/utils/selabel_digest.c b/libselinux/utils/selabel_digest.c index 1e9fb34c46ec..38162a5b3343 100644 --- a/libselinux/utils/selabel_digest.c +++ b/libselinux/utils/selabel_digest.c @@ -59,11 +59,11 @@ static int run_check_digest(char *cmd, char *selabel_digest) int main(int argc, char **argv) { - int backend = 0, rc, opt, i, validate = 0; + int backend = 0, rc, opt, validate = 0; char *baseonly = NULL, *file = NULL, *digest = (char *)1; char **specfiles = NULL; unsigned char *sha1_digest = NULL; - size_t num_specfiles; + size_t i, num_specfiles; char cmd_buf[4096]; char *cmd_ptr;