summary refs log tree commit diff
diff options
context:
space:
mode:
authorMiguel Ojeda <ojeda@kernel.org>2022-05-02 11:36:25 +0200
committerShuah Khan <skhan@linuxfoundation.org>2022-05-16 13:23:00 -0600
commit7466886b400b1904ce30fa311904849e314a2cf4 (patch)
tree8507f2f6ad0365f187344d491e6e5417857944ac
parent0453f984a7b9458f0e469afb039f2841308b1bef (diff)
downloadlinux-7466886b400b1904ce30fa311904849e314a2cf4.tar.gz
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`.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
-rw-r--r--include/kunit/test.h2
-rw-r--r--lib/kunit/test.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 607e02b8e167..8ffcd7de9607 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -508,7 +508,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 65c56bd0545d..a5053a07409f 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -244,7 +244,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;
@@ -284,7 +284,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;