Commit d2733a02 authored by David Gow's avatar David Gow Committed by Shuah Khan
Browse files

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: 0ea09083 ("lib/cmdline: Allow get_options() to take 0 to validate the input")
Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 6f2f793f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ static void cmdline_do_one_range_test(struct kunit *test, const char *in,
			    n, e[0], r[0]);

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

static void cmdline_test_range(struct kunit *test)