From: "Yu-Chun Lin [林祐君]" <eleanor.lin@realtek.com>
To: titouan <titouan.ameline@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "kees@kernel.org" <kees@kernel.org>,
"davidgow@google.com" <davidgow@google.com>,
"raemoar63@gmail.com" <raemoar63@gmail.com>,
"visitorckw@gmail.com" <visitorckw@gmail.com>,
titouan <titouan.ameline-de-cadeville@epita.fr>
Subject: RE: [PATCH] lib: math: tests: drop unnecessary KUnit param_value casts
Date: Mon, 2 Feb 2026 09:43:08 +0000 [thread overview]
Message-ID: <c7ebce2ec5c341fb98584dfd6e7d6531@realtek.com> (raw)
In-Reply-To: <20260201004743.109528-1-titouan.ameline-de-cadeville@epita.fr>
Hi,
> Drop unnecessary casts from KUnit parameter access since param_value is a
> void *. This improves readability and follows common kernel style.
>
> No functional change.
>
> Signed-off-by: melinoix <titouan.ameline@gmail.com>
Please use your real name.
> ---
> lib/math/tests/gcd_kunit.c | 2 +-
> lib/math/tests/int_log_kunit.c | 4 ++-- lib/math/tests/int_pow_kunit.c |
> 2 +- lib/math/tests/int_sqrt_kunit.c | 2 +- lib/math/tests/rational_kunit.c |
> 6 +++---
> 5 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/lib/math/tests/gcd_kunit.c b/lib/math/tests/gcd_kunit.c index
> ede1883583b1..b9c9b8758991 100644
> --- a/lib/math/tests/gcd_kunit.c
> +++ b/lib/math/tests/gcd_kunit.c
> @@ -34,7 +34,7 @@ KUNIT_ARRAY_PARAM(gcd, params, get_desc);
>
> static void gcd_test(struct kunit *test) {
> - const struct test_case_params *tc = (const struct test_case_params
> *)test->param_value;
> + const struct test_case_params *tc = test->param_value;
>
Looks valid, but it's up to the maintainer if he wants this cleanup.
> KUNIT_EXPECT_EQ(test, tc->expected_result, gcd(tc->val1,
> tc->val2)); } diff --git a/lib/math/tests/int_log_kunit.c
> b/lib/math/tests/int_log_kunit.c index 14e854146cb4..9f9b48232701 100644
> --- a/lib/math/tests/int_log_kunit.c
> +++ b/lib/math/tests/int_log_kunit.c
> @@ -43,7 +43,7 @@ KUNIT_ARRAY_PARAM(intlog2, intlog2_params,
> get_desc);
>
> static void intlog2_test(struct kunit *test) {
> - const struct test_case_params *tc = (const struct test_case_params
> *)test->param_value;
> + const struct test_case_params *tc = test->param_value;
>
> KUNIT_EXPECT_EQ(test, tc->expected_result, intlog2(tc->value)); }
> @@ -52,7 +52,7 @@ KUNIT_ARRAY_PARAM(intlog10, intlog10_params,
> get_desc);
>
> static void intlog10_test(struct kunit *test) {
> - const struct test_case_params *tc = (const struct test_case_params
> *)test->param_value;
> + const struct test_case_params *tc = test->param_value;
>
> KUNIT_EXPECT_EQ(test, tc->expected_result, intlog10(tc->value)); }
> diff --git a/lib/math/tests/int_pow_kunit.c b/lib/math/tests/int_pow_kunit.c
> index 34b33677d458..ef9c8a9bd8ac 100644
> --- a/lib/math/tests/int_pow_kunit.c
> +++ b/lib/math/tests/int_pow_kunit.c
> @@ -31,7 +31,7 @@ KUNIT_ARRAY_PARAM(int_pow, params, get_desc);
>
> static void int_pow_test(struct kunit *test) {
> - const struct test_case_params *tc = (const struct test_case_params
> *)test->param_value;
> + const struct test_case_params *tc = test->param_value;
>
> KUNIT_EXPECT_EQ(test, tc->expected_result, int_pow(tc->base,
> tc->exponent)); } diff --git a/lib/math/tests/int_sqrt_kunit.c
> b/lib/math/tests/int_sqrt_kunit.c index 1798e1312eb7..9c46024b0fc1 100644
> --- a/lib/math/tests/int_sqrt_kunit.c
> +++ b/lib/math/tests/int_sqrt_kunit.c
> @@ -45,7 +45,7 @@ KUNIT_ARRAY_PARAM(int_sqrt, params, get_desc);
>
> static void int_sqrt_test(struct kunit *test) {
> - const struct test_case_params *tc = (const struct test_case_params
> *)test->param_value;
> + const struct test_case_params *tc = test->param_value;
>
> KUNIT_EXPECT_EQ(test, tc->expected_result, int_sqrt(tc->x)); } diff
> --git a/lib/math/tests/rational_kunit.c b/lib/math/tests/rational_kunit.c index
> 47486a95f088..a405d16116df 100644
> --- a/lib/math/tests/rational_kunit.c
> +++ b/lib/math/tests/rational_kunit.c
> @@ -14,10 +14,10 @@ struct rational_test_param {
>
> static const struct rational_test_param test_parameters[] = {
> { 1230, 10, 100, 20, 100, 1, "Exceeds bounds,
> semi-convergent term > 1/2 last term" },
> - { 34567,100, 120, 20, 120, 1, "Exceeds bounds,
> semi-convergent term < 1/2 last term" },
> + { 34567, 100, 120, 20, 120, 1, "Exceeds bounds,
> semi-convergent term < 1/2 last term" },
> { 1, 30, 100, 10, 0, 1, "Closest to zero" },
> { 1, 19, 100, 10, 1, 10, "Closest to smallest
> non-zero" },
> - { 27,32, 16, 16, 11, 13, "Use convergent" },
> + { 27, 32, 16, 16, 11, 13, "Use convergent" },
These fixes are unrelated to the subject of this patch.
Best Regards,
Yu-Chun
> { 1155, 7735, 255, 255, 33, 221, "Exact answer" },
> { 87, 32, 70, 32, 68, 25, "Semiconvergent,
> numerator limit" },
> { 14533, 4626, 15000, 2400, 7433, 2366, "Semiconvergent,
> denominator limit" },
> @@ -33,7 +33,7 @@ KUNIT_ARRAY_PARAM(rational, test_parameters,
> get_desc);
>
> static void rational_test(struct kunit *test) {
> - const struct rational_test_param *param = (const struct
> rational_test_param *)test->param_value;
> + const struct rational_test_param *param = test->param_value;
> unsigned long n = 0, d = 0;
>
> rational_best_approximation(param->num, param->den,
> param->max_num, param->max_den, &n, &d);
> --
> 2.44.2
prev parent reply other threads:[~2026-02-02 9:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-01 0:47 [PATCH] lib: math: tests: drop unnecessary KUnit param_value casts titouan
2026-02-02 9:43 ` Yu-Chun Lin [林祐君] [this message]
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=c7ebce2ec5c341fb98584dfd6e7d6531@realtek.com \
--to=eleanor.lin@realtek.com \
--cc=davidgow@google.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=raemoar63@gmail.com \
--cc=titouan.ameline-de-cadeville@epita.fr \
--cc=titouan.ameline@gmail.com \
--cc=visitorckw@gmail.com \
/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