[PATCH next 6/8] test_hexdump: If a test fails print all the parameters

David Laight
2025-03-08T09:35:19Z

Print the returned lengths as signed integers.
While they shouldn't be negative, -1 is better than 18446744073709551615.
The string outputs were also incorrectly truncated.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
---
lib/test_hexdump.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c
index 07a8cc7e9088..56c0dfbd075b 100644
--- a/lib/test_hexdump.c
+++ b/lib/test_hexdump.c
@@ -146,13 +146,12 @@ static void __init test_hexdump_overflow(size_t buflen, size_t len,

ok = result == expected && !memcmp(test, buf, TEST_HEXDUMP_BUF_SIZE);

- buf[sizeof(buf) - 1] = '\0';
-
if (!ok) {
- pr_err("Len: %zu buflen: %zu strlen: %zu\n",
+ pr_err("Rowsize %zu, groupsize %zu, ascii %s, len %zu, buflen %zu, strlen %zu\n",
+ rowsize, groupsize, ascii ? "yes" : "no",
len, buflen, strnlen(buf, sizeof(buf)));
- pr_err("Result: %zu '%s'\n", result, buf);
- pr_err("Expect: %zu '%s'\n", expected, test);
+ pr_err("Result: %zd '%.*s'\n", result, TEST_HEXDUMP_BUF_SIZE, buf);
+ pr_err("Expect: %zd '%.*s'\n", expected, TEST_HEXDUMP_BUF_SIZE, test);
failed_tests++;
}
}
--
2.39.5