]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kunit: take `kunit_assert` as `const`
authorMiguel Ojeda <ojeda@kernel.org>
Mon, 2 May 2022 09:36:25 +0000 (11:36 +0200)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 16 May 2022 19:23:00 +0000 (13:23 -0600)
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>
include/kunit/test.h
lib/kunit/test.c

index 607e02b8e167cd8b894c2b7b02fe5a07496922a2..8ffcd7de96070d303d62074e3cf025a4025bbbcb 100644 (file)
@@ -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 { \
index 65c56bd0545d6c9bbcfa3f84cabd2b1a0526e611..a5053a07409ff9c855fe49f10c60d118121dd41e 100644 (file)
@@ -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;