From de0bb3be78a40ba7bc4f78a71dd57e9cf4f38f30 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 20 Oct 2026 14:54:01 +0300 Subject: [PATCH] kunit: Annotate user pointers passed to event assertions KUNIT_EXPECT_PTR_EQ stores both operands in ordinary const void pointer fields when reporting a failure. Passing the event fixture's __user tokens directly produces two Sparse address-space warnings per assertion. Explicitly cast the operands with __force at the three assertion sites. Keep the __user annotations on the stub parameters and shared token, and retain pointer equality checks and address reporting without dereferencing the token. --- scst/src/kunit/event/scst_event_fixture.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scst/src/kunit/event/scst_event_fixture.c b/scst/src/kunit/event/scst_event_fixture.c index f9b304bba..ac7d0e9dd 100644 --- a/scst/src/kunit/event/scst_event_fixture.c +++ b/scst/src/kunit/event/scst_event_fixture.c @@ -8,7 +8,8 @@ static int event_test_get_size(s32 *size, const void __user *arg) struct kunit *test = kunit_get_current_test(); struct event_test_fixture *f = test->priv; - KUNIT_EXPECT_PTR_EQ(test, arg, event_test_arg); + KUNIT_EXPECT_PTR_EQ(test, (__force const void *)arg, + (__force const void *)event_test_arg); f->reads++; if (!f->read_error) *size = f->user_size; @@ -30,7 +31,8 @@ static int event_test_put_size(s32 size, void __user *arg) struct kunit *test = kunit_get_current_test(); struct event_test_fixture *f = test->priv; - KUNIT_EXPECT_PTR_EQ(test, arg, event_test_arg); + KUNIT_EXPECT_PTR_EQ(test, (__force const void *)arg, + (__force const void *)event_test_arg); f->puts++; f->needed_size = size; return f->put_error; @@ -52,7 +54,8 @@ static unsigned long event_test_copy_from(void *to, const void __user *from, siz struct event_test_fixture *f = test->priv; size_t left = min(f->from_left, size); - KUNIT_EXPECT_PTR_EQ(test, from, event_test_arg); + KUNIT_EXPECT_PTR_EQ(test, (__force const void *)from, + (__force const void *)event_test_arg); f->imports++; f->imported = size; /* Reject the historical entry-size copy before it can overrun the fixture. */