2022-05-23 06:35:09

by Miguel Ojeda

[permalink] [raw]
Subject: [PATCH v7 04/25] kunit: take `kunit_assert` as `const`

The `kunit_do_failed_assertion` function passes its
`struct kunit_assert` argument to `kunit_fail`. This one,
in turn, calls its `format` field passing the assert again
as a `const` pointer.

Therefore, the whole chain may be made `const`.

Reviewed-by: Daniel Latypov <[email protected]>
Reviewed-by: Brendan Higgins <[email protected]>
Signed-off-by: Miguel Ojeda <[email protected]>
---
This is a prerequisite patch, independently submitted at:

https://lore.kernel.org/lkml/[email protected]/

include/kunit/test.h | 2 +-
lib/kunit/test.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/kunit/test.h b/include/kunit/test.h
index 00b9ff7783ab..2eff4f1beb42 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -774,7 +774,7 @@ void __printf(2, 3) kunit_log_append(char *log, const char *fmt, ...);
void kunit_do_failed_assertion(struct kunit *test,
const struct kunit_loc *loc,
enum kunit_assert_type type,
- struct kunit_assert *assert,
+ const struct kunit_assert *assert,
const char *fmt, ...);

#define KUNIT_ASSERTION(test, assert_type, pass, assert_class, INITIALIZER, fmt, ...) do { \
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 3bca3bf5c15b..b84aed09a009 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -241,7 +241,7 @@ static void kunit_print_string_stream(struct kunit *test,
}

static void kunit_fail(struct kunit *test, const struct kunit_loc *loc,
- enum kunit_assert_type type, struct kunit_assert *assert,
+ enum kunit_assert_type type, const struct kunit_assert *assert,
const struct va_format *message)
{
struct string_stream *stream;
@@ -281,7 +281,7 @@ static void __noreturn kunit_abort(struct kunit *test)
void kunit_do_failed_assertion(struct kunit *test,
const struct kunit_loc *loc,
enum kunit_assert_type type,
- struct kunit_assert *assert,
+ const struct kunit_assert *assert,
const char *fmt, ...)
{
va_list args;
--
2.36.1



2022-05-23 18:30:49

by Daniel Latypov

[permalink] [raw]
Subject: Re: [PATCH v7 04/25] kunit: take `kunit_assert` as `const`

On Sun, May 22, 2022 at 7:03 PM Miguel Ojeda <[email protected]> wrote:
>
> The `kunit_do_failed_assertion` function passes its
> `struct kunit_assert` argument to `kunit_fail`. This one,
> in turn, calls its `format` field passing the assert again
> as a `const` pointer.
>
> Therefore, the whole chain may be made `const`.
>
> Reviewed-by: Daniel Latypov <[email protected]>
> Reviewed-by: Brendan Higgins <[email protected]>
> Signed-off-by: Miguel Ojeda <[email protected]>
> ---
> This is a prerequisite patch, independently submitted at:
>
> https://lore.kernel.org/lkml/[email protected]/

FYI, we'd asked Shuah to pick this patch up in her "kunit" branch.
It's applied here:
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/?h=kunit&id=7466886b400b1904ce30fa311904849e314a2cf4

It had previously seemed unclear if this series could make it for the
5.19 merge window (but it now looks like there's interest in trying it
out early on).

Daniel

2022-05-23 18:38:28

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH v7 04/25] kunit: take `kunit_assert` as `const`

On 5/23/22 11:15 AM, Daniel Latypov wrote:
> On Sun, May 22, 2022 at 7:03 PM Miguel Ojeda <[email protected]> wrote:
>>
>> The `kunit_do_failed_assertion` function passes its
>> `struct kunit_assert` argument to `kunit_fail`. This one,
>> in turn, calls its `format` field passing the assert again
>> as a `const` pointer.
>>
>> Therefore, the whole chain may be made `const`.
>>
>> Reviewed-by: Daniel Latypov <[email protected]>
>> Reviewed-by: Brendan Higgins <[email protected]>
>> Signed-off-by: Miguel Ojeda <[email protected]>
>> ---
>> This is a prerequisite patch, independently submitted at:
>>
>> https://lore.kernel.org/lkml/[email protected]/
>
> FYI, we'd asked Shuah to pick this patch up in her "kunit" branch.
> It's applied here:
> https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/?h=kunit&id=7466886b400b1904ce30fa311904849e314a2cf4
>
> It had previously seemed unclear if this series could make it for the
> 5.19 merge window (but it now looks like there's interest in trying it
> out early on).
>
> Daniel
>

I am just about send pull request with this patch included.

thanks,
-- Shuah

2022-05-24 19:05:55

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH v7 04/25] kunit: take `kunit_assert` as `const`

On Mon, May 23, 2022 at 8:14 PM Shuah Khan <[email protected]> wrote:
>
> On 5/23/22 11:15 AM, Daniel Latypov wrote:
> >
> > FYI, we'd asked Shuah to pick this patch up in her "kunit" branch.
> > It's applied here:
> > https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/?h=kunit&id=7466886b400b1904ce30fa311904849e314a2cf4
> >
> > It had previously seemed unclear if this series could make it for the
> > 5.19 merge window (but it now looks like there's interest in trying it
> > out early on).
>
> I am just about send pull request with this patch included.

Thank you, Daniel and Shuah!

Cheers,
Miguel