mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
platform/wmi: string-kunit: Add missing oversized string test case
When compiling the WMI string kunit tests using llvm, the compiler
will issue a warning about "oversized_test_utf8_string" being unused.
This happens because the test case that was supposed to use said
variable was accidentally omitted when adding the kunit tests.
Fix this by adding the aforementioned test case.
Fixes: 0e1a8143e7 ("platform/wmi: Add kunit test for the string conversion code")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/platform-driver-x86/20260122234521.GA413183@ax162/
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20260123211537.4448-1-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
committed by
Ilpo Järvinen
parent
8164a14b15
commit
5d4ae0bffb
@@ -228,6 +228,23 @@ static void wmi_string_to_utf8s_oversized_test(struct kunit *test)
|
||||
KUNIT_EXPECT_MEMEQ(test, result, test_utf8_string, sizeof(test_utf8_string));
|
||||
}
|
||||
|
||||
static void wmi_string_from_utf8s_oversized_test(struct kunit *test)
|
||||
{
|
||||
struct wmi_string *result;
|
||||
size_t max_chars;
|
||||
ssize_t ret;
|
||||
|
||||
max_chars = (TEST_WMI_STRING_LENGTH - sizeof(*result)) / 2;
|
||||
result = kunit_kzalloc(test, TEST_WMI_STRING_LENGTH, GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, result);
|
||||
|
||||
ret = wmi_string_from_utf8s(result, max_chars, oversized_test_utf8_string,
|
||||
sizeof(oversized_test_utf8_string));
|
||||
|
||||
KUNIT_EXPECT_EQ(test, ret, sizeof(test_utf8_string) - 1);
|
||||
KUNIT_EXPECT_MEMEQ(test, result, &test_wmi_string, sizeof(test_wmi_string));
|
||||
}
|
||||
|
||||
static void wmi_string_to_utf8s_invalid_test(struct kunit *test)
|
||||
{
|
||||
u8 result[sizeof(invalid_test_utf8_string)];
|
||||
@@ -261,6 +278,7 @@ static struct kunit_case wmi_string_test_cases[] = {
|
||||
KUNIT_CASE(wmi_string_to_utf8s_padded_test),
|
||||
KUNIT_CASE(wmi_string_from_utf8s_padded_test),
|
||||
KUNIT_CASE(wmi_string_to_utf8s_oversized_test),
|
||||
KUNIT_CASE(wmi_string_from_utf8s_oversized_test),
|
||||
KUNIT_CASE(wmi_string_to_utf8s_invalid_test),
|
||||
KUNIT_CASE(wmi_string_from_utf8s_invalid_test),
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user