* [PATCH RESEND v2] Documentation: KUnit: Fix example with compilation error
@ 2022-07-20 18:57 Maíra Canal
2022-07-21 18:27 ` Daniel Latypov
2022-07-26 5:27 ` Brendan Higgins
0 siblings, 2 replies; 3+ messages in thread
From: Maíra Canal @ 2022-07-20 18:57 UTC (permalink / raw)
To: Brendan Higgins, Jonathan Corbet, davidgow
Cc: linux-kselftest, kunit-dev, linux-doc, linux-kernel, Maíra Canal
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>
---
v1 -> v2: https://lore.kernel.org/linux-kselftest/CABVgOSkFKJBNt-AsWmOh2Oni4QO2xdiXJiYD1EVcS-Qz=BjJRw@mail.gmail.com/T/#mf546fc75bf9e5bd27cb3bbd531b51409fbc87a9d
- Instead of changing the function signature to non-const, makes the cases
const (David Gow).
---
Documentation/dev-tools/kunit/usage.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
index d62a04255c2e..44158eecb51e 100644
--- a/Documentation/dev-tools/kunit/usage.rst
+++ b/Documentation/dev-tools/kunit/usage.rst
@@ -505,7 +505,7 @@ By reusing the same ``cases`` array from above, we can write the test as a
const char *str;
const char *sha1;
};
- struct sha1_test_case cases[] = {
+ const struct sha1_test_case cases[] = {
{
.str = "hello world",
.sha1 = "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed",
--
2.36.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND v2] Documentation: KUnit: Fix example with compilation error
2022-07-20 18:57 [PATCH RESEND v2] Documentation: KUnit: Fix example with compilation error Maíra Canal
@ 2022-07-21 18:27 ` Daniel Latypov
2022-07-26 5:27 ` Brendan Higgins
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Latypov @ 2022-07-21 18:27 UTC (permalink / raw)
To: Maíra Canal
Cc: Brendan Higgins, Jonathan Corbet, davidgow, linux-kselftest,
kunit-dev, linux-doc, linux-kernel
On Wed, Jul 20, 2022 at 11:57 AM Maíra Canal <mairacanal@riseup.net> wrote:
>
> 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>
Thanks for fixing this!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND v2] Documentation: KUnit: Fix example with compilation error
2022-07-20 18:57 [PATCH RESEND v2] Documentation: KUnit: Fix example with compilation error Maíra Canal
2022-07-21 18:27 ` Daniel Latypov
@ 2022-07-26 5:27 ` Brendan Higgins
1 sibling, 0 replies; 3+ messages in thread
From: Brendan Higgins @ 2022-07-26 5:27 UTC (permalink / raw)
To: Maíra Canal
Cc: Jonathan Corbet, davidgow, linux-kselftest, kunit-dev, linux-doc,
linux-kernel
On Wed, Jul 20, 2022 at 2:57 PM Maíra Canal <mairacanal@riseup.net> wrote:
>
> 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>
Thanks!
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-26 5:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 18:57 [PATCH RESEND v2] Documentation: KUnit: Fix example with compilation error Maíra Canal
2022-07-21 18:27 ` Daniel Latypov
2022-07-26 5:27 ` Brendan Higgins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).