diff mbox series

[v7,04/25] kunit: take `kunit_assert` as `const`

Message ID 20220523020209.11810-5-ojeda@kernel.org (mailing list archive)
State Accepted
Commit 7466886b400b1904ce30fa311904849e314a2cf4
Delegated to: Brendan Higgins
Headers show
Series Rust support | expand

Commit Message

Miguel Ojeda May 23, 2022, 2:01 a.m. UTC
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 <dlatypov@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
This is a prerequisite patch, independently submitted at:

    https://lore.kernel.org/lkml/20220502093625.GA23225@kernel.org/

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

Comments

Daniel Latypov May 23, 2022, 5:15 p.m. UTC | #1
On Sun, May 22, 2022 at 7:03 PM Miguel Ojeda <ojeda@kernel.org> 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 <dlatypov@google.com>
> Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> This is a prerequisite patch, independently submitted at:
>
>     https://lore.kernel.org/lkml/20220502093625.GA23225@kernel.org/

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
Shuah Khan May 23, 2022, 6:14 p.m. UTC | #2
On 5/23/22 11:15 AM, Daniel Latypov wrote:
> On Sun, May 22, 2022 at 7:03 PM Miguel Ojeda <ojeda@kernel.org> 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 <dlatypov@google.com>
>> Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
>> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
>> ---
>> This is a prerequisite patch, independently submitted at:
>>
>>      https://lore.kernel.org/lkml/20220502093625.GA23225@kernel.org/
> 
> 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
Miguel Ojeda May 24, 2022, 12:37 p.m. UTC | #3
On Mon, May 23, 2022 at 8:14 PM Shuah Khan <skhan@linuxfoundation.org> 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
diff mbox series

Patch

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;