Skip to content

Commit 1bddcf7

Browse files
rfvirgilshuahkh
authored andcommitted
kunit: test: Avoid cast warning when adding kfree() as an action
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: 05e2006 ("kunit: Use string_stream for test log") Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 2e3c94a commit 1bddcf7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/kunit/kunit-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static void kunit_log_test(struct kunit *test)
562562
KUNIT_EXPECT_TRUE(test, test->log->append_newlines);
563563

564564
full_log = string_stream_get_string(test->log);
565-
kunit_add_action(test, (kunit_action_t *)kfree, full_log);
565+
kunit_add_action(test, kfree_wrapper, full_log);
566566
KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
567567
strstr(full_log, "put this in log."));
568568
KUNIT_EXPECT_NOT_ERR_OR_NULL(test,

0 commit comments

Comments
 (0)