Skip to contentSkip to conversation

selftests: lsm: Refactor `flags_overset_lsm_set_self_attr` test

PATCH In review Amit Vadhavana 2 participants 2 messages Nov 16, 2024 – Dec 18, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests: lsm: Refactor `flags_overset_lsm_set_self_attr` test

Remove the temporary context variable tctx to simplify the code. use the original context ctx directly in calls to lsm_get_self_attr, eliminating redundancy without any functional changes.

---
V1:- https://lore.kernel.org/all/[email protected]/
V1 -> V2 :
write complete sentences instead of bullet points in the change log.

---
 tools/testing/selftests/lsm/lsm_set_self_attr_test.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
tools/testing/selftests/lsm/lsm_set_self_attr_test.c +3 -4
index 66dec47e3ca3..732e89fe99c0 100644
@@ -56,16 +56,15 @@ TEST(flags_zero_lsm_set_self_attr)
 TEST(flags_overset_lsm_set_self_attr)
 {
 	const long page_size = sysconf(_SC_PAGESIZE);
-	char *ctx = calloc(page_size, 1);
+	struct lsm_ctx *ctx = calloc(page_size, 1);
 	__u32 size = page_size;
-	struct lsm_ctx *tctx = (struct lsm_ctx *)ctx;
 
 	ASSERT_NE(NULL, ctx);
 	if (attr_lsm_count()) {
-		ASSERT_LE(1, lsm_get_self_attr(LSM_ATTR_CURRENT, tctx, &size,
+		ASSERT_LE(1, lsm_get_self_attr(LSM_ATTR_CURRENT, ctx, &size,
 					       0));
 	}
-	ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT | LSM_ATTR_PREV, tctx,
+	ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT | LSM_ATTR_PREV, ctx,
 					size, 0));
 
 	free(ctx);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · On Nov 16, 2024 Amit Vadhavana <[email protected]> wrote:

Remove the temporary context variable tctx to simplify the code. use the original context ctx directly in calls to lsm_get_self_attr, eliminating redundancy without any functional changes.

Quoted 7 lines

---
V1:- https://lore.kernel.org/all/[email protected]/
V1 -> V2 :
write complete sentences instead of bullet points in the change log.

---
 tools/testing/selftests/lsm/lsm_set_self_attr_test.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Thank you for working on improving the tests, merged into lsm/dev.

--
paul-moore.com