summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-05-11 12:52:48 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-08-07 21:07:58 -0400
commit34f90d14efc2f3ced54c72717a37fc4fcc9a1d85 (patch)
treeae205e79f92f769bc35ecd9f2f710f227a2642d2
parent021894b48d111c7dc5cf63fb29f294ccf4068842 (diff)
test_printf: Drop requirement that sprintf not write past nul
The current test code checks that sprintf never writes past the terminating nul. This is a rather strange requirement, completely separate from writing past the end of the buffer, which of course we can't do: writing anywhere to the buffer passed to snprintf, within size of course, should be perfectly fine. Since this check has no documentation as to where it comes from or what depends on it, and it's getting in the way of further refactoring (printf_spec handling is right now scattered massively throughout the code, and we'd like to consolidate it) - delete it. Also, many current pretty-printers building up their output on the stack, and then copy it to the actual output buffer - by eliminating this requirement we can kill those extra buffers. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
-rw-r--r--lib/test_printf.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 4bd15a593fbd..da91301eae50 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -84,12 +84,6 @@ do_test(int bufsize, const char *expect, int elen,
return 1;
}
- if (memchr_inv(test_buffer + written + 1, FILL_CHAR, bufsize - (written + 1))) {
- pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote beyond the nul-terminator\n",
- bufsize, fmt);
- return 1;
- }
-
if (memchr_inv(test_buffer + bufsize, FILL_CHAR, BUF_SIZE + PAD_SIZE - bufsize)) {
pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote beyond buffer\n", bufsize, fmt);
return 1;