Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: refactor the lsm `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.

Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Amit Vadhavana <av2082000@gmail.com>
[PM: subject tweak]
Signed-off-by: Paul Moore <paul@paul-moore.com>

authored by

Amit Vadhavana and committed by
Paul Moore
7a9b65ab 01292013

+3 -4
+3 -4
tools/testing/selftests/lsm/lsm_set_self_attr_test.c
··· 56 56 TEST(flags_overset_lsm_set_self_attr) 57 57 { 58 58 const long page_size = sysconf(_SC_PAGESIZE); 59 - char *ctx = calloc(page_size, 1); 59 + struct lsm_ctx *ctx = calloc(page_size, 1); 60 60 __u32 size = page_size; 61 - struct lsm_ctx *tctx = (struct lsm_ctx *)ctx; 62 61 63 62 ASSERT_NE(NULL, ctx); 64 63 if (attr_lsm_count()) { 65 - ASSERT_LE(1, lsm_get_self_attr(LSM_ATTR_CURRENT, tctx, &size, 64 + ASSERT_LE(1, lsm_get_self_attr(LSM_ATTR_CURRENT, ctx, &size, 66 65 0)); 67 66 } 68 - ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT | LSM_ATTR_PREV, tctx, 67 + ASSERT_EQ(-1, lsm_set_self_attr(LSM_ATTR_CURRENT | LSM_ATTR_PREV, ctx, 69 68 size, 0)); 70 69 71 70 free(ctx);