Skip to content

Commit ba407fc

Browse files
committed
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]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 61968db commit ba407fc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/kunit/test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ void __printf(2, 3) kunit_log_append(char *log, const char *fmt, ...);
774774
void kunit_do_failed_assertion(struct kunit *test,
775775
const struct kunit_loc *loc,
776776
enum kunit_assert_type type,
777-
struct kunit_assert *assert,
777+
const struct kunit_assert *assert,
778778
const char *fmt, ...);
779779

780780
#define KUNIT_ASSERTION(test, assert_type, pass, assert_class, INITIALIZER, fmt, ...) do { \

lib/kunit/test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static void kunit_print_string_stream(struct kunit *test,
241241
}
242242

243243
static void kunit_fail(struct kunit *test, const struct kunit_loc *loc,
244-
enum kunit_assert_type type, struct kunit_assert *assert,
244+
enum kunit_assert_type type, const struct kunit_assert *assert,
245245
const struct va_format *message)
246246
{
247247
struct string_stream *stream;
@@ -281,7 +281,7 @@ static void __noreturn kunit_abort(struct kunit *test)
281281
void kunit_do_failed_assertion(struct kunit *test,
282282
const struct kunit_loc *loc,
283283
enum kunit_assert_type type,
284-
struct kunit_assert *assert,
284+
const struct kunit_assert *assert,
285285
const char *fmt, ...)
286286
{
287287
va_list args;

0 commit comments

Comments
 (0)