Skip to content

Commit 4c39251

Browse files
mairacanalshuahkh
authored andcommitted
Documentation: KUnit: Fix example with compilation error
The Parameterized Testing example contains a compilation error, as the signature for the description helper function is void(*)(const struct sha1_test_case *, char *), and the struct is non-const. This is warned by Clang: error: initialization of ‘void (*)(struct sha1_test_case *, char *)’ from incompatible pointer type ‘void (*)(const struct sha1_test_case *, char *)’ [-Werror=incompatible-pointer-types] 33 | KUNIT_ARRAY_PARAM(sha1, cases, case_to_desc); | ^~~~~~~~~~~~ ../include/kunit/test.h:1339:70: note: in definition of macro ‘KUNIT_ARRAY_PARAM’ 1339 | void (*__get_desc)(typeof(__next), char *) = get_desc; \ Signed-off-by: Maíra Canal <mairacanal@riseup.net> Reviewed-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 9570638 commit 4c39251

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Documentation/dev-tools/kunit/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ By reusing the same ``cases`` array from above, we can write the test as a
505505
const char *str;
506506
const char *sha1;
507507
};
508-
struct sha1_test_case cases[] = {
508+
const struct sha1_test_case cases[] = {
509509
{
510510
.str = "hello world",
511511
.sha1 = "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed",

0 commit comments

Comments
 (0)