From: Armin Wolf <W_Armin@gmx.de>
To: Nathan Chancellor <nathan@kernel.org>
Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, linux@weissschuh.net,
Dell.Client.Kernel@dell.com, corbet@lwn.net,
linux-doc@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH v3 4/9] platform/wmi: Add kunit test for the string conversion code
Date: Fri, 23 Jan 2026 20:17:12 +0100 [thread overview]
Message-ID: <218f7a67-9be2-4094-b400-1cfad3fd9d0a@gmx.de> (raw)
In-Reply-To: <20260122234521.GA413183@ax162>
Am 23.01.26 um 00:45 schrieb Nathan Chancellor:
> Hi Armin,
>
> On Fri, Jan 09, 2026 at 10:46:14PM +0100, Armin Wolf wrote:
>> The string conversion frunctions provided by the WMI driver core
>> have no dependencies on the remaining WMI API, making them suitable
>> for unit tests.
>>
>> Implement such a unit test using kunit. Those unit tests verify that
>> converting between WMI strings and UTF8 strings works as expected.
>> They also verify that edge cases are handled correctly.
>>
>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ...
>> +++ b/drivers/platform/wmi/tests/string_kunit.c
> ...
>> +static const u8 oversized_test_utf8_string[] = "TEST!";
> ...
>> +static void wmi_string_to_utf8s_oversized_test(struct kunit *test)
>> +{
>> + u8 result[sizeof(oversized_test_utf8_string)];
>> + ssize_t ret;
>> +
>> + ret = wmi_string_to_utf8s(&oversized_test_wmi_string, result, sizeof(result));
>> +
>> + KUNIT_EXPECT_EQ(test, ret, sizeof(test_utf8_string) - 1);
>> + KUNIT_EXPECT_MEMEQ(test, result, test_utf8_string, sizeof(test_utf8_string));
>> +}
> After this change in -next as commit 0e1a8143e797 ("platform/wmi: Add
> kunit test for the string conversion code"), I am seeing a warning from
> clang around oversized_test_utf8_string:
>
> drivers/platform/wmi/tests/string_kunit.c:108:17: error: variable 'oversized_test_utf8_string' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
> 108 | static const u8 oversized_test_utf8_string[] = "TEST!";
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~
>
> oversized_test_utf8_string is only used in sizeof() in
> wmi_string_to_utf8s_oversized_test(). clang warns because sizeof() is
> evaluated at compile time, so oversized_test_utf8_string won't end up in
> the final binary. This is typically a bug since the developer may have
> intended to use the variable elsewhere but I was not able to easily
> determine that in this case.
>
> If it is intentional that this variable is only needed in sizeof(), it
> could either be marked with __maybe_unused or eliminated in favor of a
> direct 'sizeof("TEST!")', depending on maintainer/developer preference.
> I am happy to send a patch.
>
> Cheers,
> Nathan
Good catch, it seems that i forgot to add the test case that was supposed to use oversized_test_utf8_string.
I will send a patch that adds this missing test case, fixing this warning in the process.
Thanks,
Armin Wolf
next prev parent reply other threads:[~2026-01-23 19:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 21:46 [PATCH v3 0/9] platform/wmi: Introduce marshalling support Armin Wolf
2026-01-09 21:46 ` [PATCH v3 1/9] " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 2/9] platform/wmi: Add kunit test for the marshalling code Armin Wolf
2026-01-09 21:46 ` [PATCH v3 3/9] platform/wmi: Add helper functions for WMI string conversions Armin Wolf
2026-01-09 21:46 ` [PATCH v3 4/9] platform/wmi: Add kunit test for the string conversion code Armin Wolf
2026-01-12 16:34 ` Ilpo Järvinen
2026-01-12 17:59 ` Armin Wolf
2026-01-12 18:11 ` Ilpo Järvinen
2026-01-22 23:45 ` Nathan Chancellor
2026-01-23 19:17 ` Armin Wolf [this message]
2026-01-09 21:46 ` [PATCH v3 5/9] platform/x86: intel-wmi-sbl-fw-update: Use new buffer-based WMI API Armin Wolf
2026-01-09 21:46 ` [PATCH v3 6/9] platform/x86/intel/wmi: thunderbolt: " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 7/9] platform/x86: xiaomi-wmi: " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 8/9] platform/x86: wmi-bmof: " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 9/9] platform/wmi: Update driver development guide Armin Wolf
2026-01-12 15:33 ` [PATCH v3 0/9] platform/wmi: Introduce marshalling support Ilpo Järvinen
2026-01-12 18:00 ` Armin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=218f7a67-9be2-4094-b400-1cfad3fd9d0a@gmx.de \
--to=w_armin@gmx.de \
--cc=Dell.Client.Kernel@dell.com \
--cc=corbet@lwn.net \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®