linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: elfring@users.sourceforge.net (SF Markus Elfring)
To: linux-security-module@vger.kernel.org
Subject: [PATCH 1/4] selinux: Delete eight unnecessary variable assignments
Date: Sun, 13 Aug 2017 16:45:10 +0200	[thread overview]
Message-ID: <05edc763-dddd-fe48-b98c-21e4ad5463a3@users.sourceforge.net> (raw)
In-Reply-To: <e9f47cc9-fda7-dc54-bca9-cae6488914e0@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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:
-- 
2.14.0

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-08-13 14:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-13 14:43 [PATCH 0/4] SELinux: Fine-tuning for some function implementations SF Markus Elfring
2017-08-13 14:45 ` SF Markus Elfring [this message]
2017-08-13 16:22   ` [PATCH 1/4] selinux: Delete eight unnecessary variable assignments Serge E. Hallyn
2017-08-13 16:24     ` Serge E. Hallyn
2017-08-13 14:46 ` [PATCH 2/4] selinux: Adjust jump targets in ebitmap_read() SF Markus Elfring
2017-08-13 16:24   ` Serge E. Hallyn
2017-08-13 14:48 ` [PATCH 3/4] selinux: Delete an unnecessary return statement in ebitmap_destroy() SF Markus Elfring
2017-08-13 14:50 ` [PATCH 4/4] selinux: Adjust five checks for null pointers SF Markus Elfring
2017-08-13 15:41   ` Serge E. Hallyn
2017-08-14 20:59 ` [PATCH 0/4] SELinux: Fine-tuning for some function implementations Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05edc763-dddd-fe48-b98c-21e4ad5463a3@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=linux-security-module@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).