Skip to content

Commit d2733a0

Browse files
sulixshuahkh
authored andcommitted
lib/cmdline: Fix an invalid format specifier in an assertion msg
The correct format specifier for p - n (both p and n are pointers) is %td, as the type should be ptrdiff_t. This was discovered by annotating KUnit assertion macros with gcc's printf specifier, but note that gcc incorrectly suggested a %d or %ld specifier (depending on the pointer size of the architecture being built). Fixes: 0ea0908 ("lib/cmdline: Allow get_options() to take 0 to validate the input") Signed-off-by: David Gow <davidgow@google.com> Tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Daniel Latypov <dlatypov@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 6f2f793 commit d2733a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/cmdline_kunit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void cmdline_do_one_range_test(struct kunit *test, const char *in,
124124
n, e[0], r[0]);
125125

126126
p = memchr_inv(&r[1], 0, sizeof(r) - sizeof(r[0]));
127-
KUNIT_EXPECT_PTR_EQ_MSG(test, p, NULL, "in test %u at %u out of bound", n, p - r);
127+
KUNIT_EXPECT_PTR_EQ_MSG(test, p, NULL, "in test %u at %td out of bound", n, p - r);
128128
}
129129

130130
static void cmdline_test_range(struct kunit *test)

0 commit comments

Comments
 (0)