mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 06:02:33 +00:00
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.
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user