diff mbox series

[12/16] libsepol: Refactor match_any_class_permissions() to be clearer

Message ID 20211217181913.336360-13-jwcart2@gmail.com (mailing list archive)
State Superseded
Headers show
Series Refactor and fix assertion checking | expand

Commit Message

James Carter Dec. 17, 2021, 6:19 p.m. UTC
Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/src/assertion.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libsepol/src/assertion.c b/libsepol/src/assertion.c
index 4c9b9557..0bd620a7 100644
--- a/libsepol/src/assertion.c
+++ b/libsepol/src/assertion.c
@@ -65,14 +65,11 @@  static void report_failure(sepol_handle_t *handle, policydb_t *p, const avrule_t
 static int match_any_class_permissions(class_perm_node_t *cp, uint32_t class, uint32_t data)
 {
 	for (; cp; cp = cp->next) {
-		if ((cp->tclass == class) && (cp->data & data)) {
-			break;
-		}
+		if ((cp->tclass == class) && (cp->data & data))
+			return 1;
 	}
-	if (!cp)
-		return 0;
 
-	return 1;
+	return 0;
 }
 
 static int extended_permissions_and(uint32_t *perms1, uint32_t *perms2) {