lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260122234521.GA413183@ax162>
Date: Thu, 22 Jan 2026 16:45:21 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Armin Wolf <W_Armin@....de>
Cc: hansg@...nel.org, ilpo.jarvinen@...ux.intel.com,
	platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux@...ssschuh.net, Dell.Client.Kernel@...l.com, corbet@....net,
	linux-doc@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH v3 4/9] platform/wmi: Add kunit test for the string
 conversion code

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@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ