From patchwork Sun Aug 13 14:45:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9897883 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 6DA2E60244 for ; Sun, 13 Aug 2017 14:46:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ACD32860F for ; Sun, 13 Aug 2017 14:46:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F1FF2861D; Sun, 13 Aug 2017 14:46:08 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1B8128616 for ; Sun, 13 Aug 2017 14:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751210AbdHMOpz (ORCPT ); Sun, 13 Aug 2017 10:45:55 -0400 Received: from mout.web.de ([212.227.15.14]:62595 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbdHMOpy (ORCPT ); Sun, 13 Aug 2017 10:45:54 -0400 Received: from [192.168.1.2] ([92.228.32.17]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MevzF-1dwXB03oRV-00OUGm; Sun, 13 Aug 2017 16:45:12 +0200 Subject: [PATCH 1/4] selinux: Delete eight unnecessary variable assignments From: SF Markus Elfring To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Alexey Dobriyan , Daniel Jurgens , Eric Paris , James Morris , Junil Lee , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <05edc763-dddd-fe48-b98c-21e4ad5463a3@users.sourceforge.net> Date: Sun, 13 Aug 2017 16:45:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:B1hr/o5h3xVszEHRrAJoOVRMvFjurNkkz+oWwa4vMqIza/G93oc tN0AkntKLTOj94zUnuJbKDCLPkngjMD7GaPM9uXHITB/uaYF5SObFJpJK/tr08iH/C5fHSP P/ugz76efCIO6hcmByxPy+xjF8yxq3Fb77+INlFmApavZo5pwqW//9iuBBra0rJDy0Fqf3F FkXfaUCwV0xXpsh0Ye9Ug== X-UI-Out-Filterresults: notjunk:1; V01:K0:yWkmqRXAswk=:5/McqTteUuBCLrNs2NEQqJ Rkx2u92Ei782j9E7q8zKqdT5BgCpMT0lUICCTbpzA6NS0O39m8cW7Ba1YHYwvTLcbEfY2L25u iMWnzHrt4sC2HFNENpQRsOTJYde/cIkz1Q6OKPQ3SPNDOgD+/e++fG57sJ6ZgsCjMnsIvlXrO tn20BBvK0ibb0Dlx+0TwDzzrrTes5iuJqn1nWAmsfPYOWNLL+NOO8Thr/J5LvqvecKYlkyboH 1PKCsIEfQyIVjL5OLMrjVhO+AfESM78hqRRL01ausUAgynOlk/iauDwG/RQJj9LDe/A+KLWg5 YXsLSy368SEIxFX/D9sCRQiFXhh8WeBRqFXu26jZllU3lfC7ZJc41bJNt4btYL1G/R/onzGIO 9IrrYZ0OEQzwJGvd0RtBS8fCqhDcMKfL3Ccus4jsVAB0Ezr5mTEfAwk8UfASzGHtBTkbPNBFt ep2f/YVrTFaf9O1dLJlEd0uI6csVAF34JCXFXAeMPcqVT+cEJZ9KA8B6zvgmGtWDYvXjMVzkx sqauJIn/4Hwo88Lr8a8Bq7z1teSuMTAkJ5DlWVHNAu3dc/SMRpokpNWOSYVrbL1TnudmGKWoU dHyw3qJERdpB/36DfkeoMVtsSklIcUdZgQDBUOUS08POS9E829Y02n+twrCA38iHxoYJDYXVu WUSVNe2kBBRsYXidnsmnexzYMX63pWmlyxQOryOuOrFum8WiezDC2MVqhpI/FHWIBH4CWX88Y cIfQJDtHrcXq1TRyBPzONxUp+Ic0IAS9bArUC841Nry4eqP72eNXeqcmMflvFDT2jUrB4gaAe uR0MXSpMaRyGgDJaxwKARD081CvBdjhKlJ0aH+w+fiZp5nvc5E= Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 13 Aug 2017 14:17:48 +0200 One local variable was reset to zero at the end of these functions. This value will also be set by a previous call of a function if it was executed successfully. Thus omit an extra assignment there. Signed-off-by: Markus Elfring Acked-by: Serge Hallyn --- security/selinux/selinuxfs.c | 1 - security/selinux/ss/avtab.c | 2 -- security/selinux/ss/ebitmap.c | 4 +--- security/selinux/ss/policydb.c | 10 ++-------- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 00eed842c491..7565c312a198 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -1724,7 +1724,6 @@ static int sel_make_classes(void) if (rc) goto out; } - rc = 0; out: for (i = 0; i < nclasses; i++) kfree(classes[i]); diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c index 3628d3a868b6..a8218905e286 100644 --- a/security/selinux/ss/avtab.c +++ b/security/selinux/ss/avtab.c @@ -587,8 +587,6 @@ int avtab_read(struct avtab *a, void *fp, struct policydb *pol) goto bad; } } - - rc = 0; out: return rc; diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c index ad38299164c3..ccf372db689c 100644 --- a/security/selinux/ss/ebitmap.c +++ b/security/selinux/ss/ebitmap.c @@ -373,7 +373,7 @@ int ebitmap_read(struct ebitmap *e, void *fp) if (!e->highbit) { e->node = NULL; - goto ok; + goto out; } if (e->highbit && !count) @@ -436,8 +436,6 @@ int ebitmap_read(struct ebitmap *e, void *fp) map = EBITMAP_SHIFT_UNIT_SIZE(map); } } -ok: - rc = 0; out: return rc; bad: diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index aa6500abb178..a2356fc263c6 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -599,7 +599,6 @@ static int policydb_index(struct policydb *p) if (rc) goto out; } - rc = 0; out: return rc; } @@ -903,10 +902,10 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) head = p->ocontexts[OCON_ISID]; for (c = head; c; c = c->next) { - rc = -EINVAL; if (!c->context[0].user) { printk(KERN_ERR "SELinux: SID %s was never defined.\n", c->u.name); + rc = -EINVAL; goto out; } @@ -917,7 +916,6 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s) goto out; } } - rc = 0; out: return rc; } @@ -1074,13 +1072,12 @@ static int context_read_and_validate(struct context *c, } } - rc = -EINVAL; if (!policydb_context_isvalid(p, c)) { printk(KERN_ERR "SELinux: invalid security context\n"); context_destroy(c); + rc = -EINVAL; goto out; } - rc = 0; out: return rc; } @@ -1900,7 +1897,6 @@ static int range_read(struct policydb *p, void *fp) r = NULL; } hash_eval(p->range_tr, "rangetr"); - rc = 0; out: kfree(rt); kfree(r); @@ -2550,8 +2546,6 @@ int policydb_read(struct policydb *p, void *fp) rc = policydb_bounds_sanity_check(p); if (rc) goto bad; - - rc = 0; out: return rc; bad: