mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] kunit: test: Avoid cast warning when adding kfree() as an action
@ 2023-11-06 17:25 Richard Fitzgerald
  2023-11-06 18:08 ` David Gow
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2023-11-06 17:25 UTC (permalink / raw)
  To: brendan.higgins, davidgow, rmoar
  Cc: linux-kselftest, kunit-dev, linux-kernel, patches,
	Richard Fitzgerald, kernel test robot

In kunit_log_test() pass the kfree_wrapper() function to kunit_add_action()
instead of directly passing kfree().

This prevents a cast warning:

lib/kunit/kunit-test.c:565:25: warning: cast from 'void (*)(const void *)'
to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible
function type [-Wcast-function-type-strict]

   564		full_log = string_stream_get_string(test->log);
 > 565		kunit_add_action(test, (kunit_action_t *)kfree, full_log);

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311070041.kWVYx7YP-lkp@intel.com/
Fixes: 05e2006ce493 ("kunit: Use string_stream for test log")
---
 lib/kunit/kunit-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c
index 99d2a3a528e1..de2113a58fa0 100644
--- a/lib/kunit/kunit-test.c
+++ b/lib/kunit/kunit-test.c
@@ -562,7 +562,7 @@ static void kunit_log_test(struct kunit *test)
 	KUNIT_EXPECT_TRUE(test, test->log->append_newlines);
 
 	full_log = string_stream_get_string(test->log);
-	kunit_add_action(test, (kunit_action_t *)kfree, full_log);
+	kunit_add_action(test, kfree_wrapper, full_log);
 	KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
 				     strstr(full_log, "put this in log."));
 	KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
-- 
2.30.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] kunit: test: Avoid cast warning when adding kfree() as an action
  2023-11-06 17:25 [PATCH v2] kunit: test: Avoid cast warning when adding kfree() as an action Richard Fitzgerald
@ 2023-11-06 18:08 ` David Gow
  0 siblings, 0 replies; 2+ messages in thread
From: David Gow @ 2023-11-06 18:08 UTC (permalink / raw)
  To: Richard Fitzgerald
  Cc: brendan.higgins, rmoar, linux-kselftest, kunit-dev, linux-kernel,
	patches, kernel test robot

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

On Mon, 6 Nov 2023 at 09:26, Richard Fitzgerald
<rf@opensource.cirrus.com> wrote:
>
> In kunit_log_test() pass the kfree_wrapper() function to kunit_add_action()
> instead of directly passing kfree().
>
> This prevents a cast warning:
>
> lib/kunit/kunit-test.c:565:25: warning: cast from 'void (*)(const void *)'
> to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible
> function type [-Wcast-function-type-strict]
>
>    564          full_log = string_stream_get_string(test->log);
>  > 565          kunit_add_action(test, (kunit_action_t *)kfree, full_log);
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202311070041.kWVYx7YP-lkp@intel.com/
> Fixes: 05e2006ce493 ("kunit: Use string_stream for test log")
> ---

Looks good to me, thanks!

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-06 18:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-06 17:25 [PATCH v2] kunit: test: Avoid cast warning when adding kfree() as an action Richard Fitzgerald
2023-11-06 18:08 ` David Gow

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®