[PATCH] A trivial simplification to shorten the code a bit.

Kalevi Kolttonen via selinux <[email protected]> Mon, 12 May 2025 22:25:06 +0300
Newsgroups gmane.linux.redhat.fedora.selinux
Message-ID <aCJLEo9yN-nbLNlZ@14-5A-FC-31-E8-67>
--eNejVUcQLbcKp0F0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

The trivial simplification patch is attached.

br,
KK

--eNejVUcQLbcKp0F0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=trivial-simplification.patch

>From 9b209da2e749ffb869ac91b90df71d14cd5970d6 Mon Sep 17 00:00:00 2001
From: Kalevi Kolttonen <[email protected]>
Date: Mon, 12 May 2025 22:14:19 +0300
Subject: [PATCH] A trivial simplification to shorten the code a bit.

---
 security/selinux/hooks.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e7a7dcab81db..337951fb81e0 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -6693,14 +6693,10 @@ static int selinux_secid_to_secctx(u32 secid, struct lsm_context *cp)
 	if (cp) {
 		cp->id = LSM_ID_SELINUX;
 		ret = security_sid_to_context(secid, &cp->context, &cp->len);
-		if (ret < 0)
-			return ret;
-		return cp->len;
+		return (ret < 0) ? ret : cp->len;
 	}
 	ret = security_sid_to_context(secid, NULL, &seclen);
-	if (ret < 0)
-		return ret;
-	return seclen;
+	return (ret < 0) ? ret : seclen;
 }
 
 static int selinux_lsmprop_to_secctx(struct lsm_prop *prop,
-- 
2.49.0


--eNejVUcQLbcKp0F0
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

LS0gCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCnNlbGlu
dXggbWFpbGluZyBsaXN0IC0tIHNlbGludXhAbGlzdHMuZmVkb3JhcHJvamVjdC5vcmcKVG8gdW5z
dWJzY3JpYmUgc2VuZCBhbiBlbWFpbCB0byBzZWxpbnV4LWxlYXZlQGxpc3RzLmZlZG9yYXByb2pl
Y3Qub3JnCkZlZG9yYSBDb2RlIG9mIENvbmR1Y3Q6IGh0dHBzOi8vZG9jcy5mZWRvcmFwcm9qZWN0
Lm9yZy9lbi1VUy9wcm9qZWN0L2NvZGUtb2YtY29uZHVjdC8KTGlzdCBHdWlkZWxpbmVzOiBodHRw
czovL2ZlZG9yYXByb2plY3Qub3JnL3dpa2kvTWFpbGluZ19saXN0X2d1aWRlbGluZXMKTGlzdCBB
cmNoaXZlczogaHR0cHM6Ly9saXN0cy5mZWRvcmFwcm9qZWN0Lm9yZy9hcmNoaXZlcy9saXN0L3Nl
bGludXhAbGlzdHMuZmVkb3JhcHJvamVjdC5vcmcKRG8gbm90IHJlcGx5IHRvIHNwYW0sIHJlcG9y
dCBpdDogaHR0cHM6Ly9wYWd1cmUuaW8vZmVkb3JhLWluZnJhc3RydWN0dXJlL25ld19pc3N1ZQo=

--eNejVUcQLbcKp0F0--