]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scanf: remove redundant debug logs
authorTamir Duberstein <tamird@gmail.com>
Fri, 7 Mar 2025 11:27:35 +0000 (06:27 -0500)
committerKees Cook <kees@kernel.org>
Fri, 14 Mar 2025 20:50:44 +0000 (13:50 -0700)
Remove `pr_debug` calls which emit information already contained in
`pr_warn` calls that occur on test failure. This reduces unhelpful test
verbosity.

Note that a `pr_debug` removed from `_check_numbers_template` appears to
have been the only guard against silent false positives, but in fact
this condition is handled in `_test`; it is only possible for `n_args`
to be `0` in `_check_numbers_template` if the test explicitly expects it
*and* `vsscanf` returns `0`, matching the expectation.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Link: https://lore.kernel.org/r/20250307-scanf-kunit-convert-v9-2-b98820fa39ff@gmail.com
Signed-off-by: Kees Cook <kees@kernel.org>
lib/test_scanf.c

index e65b10c3dc118f1d432833c1d6c049d8b0ef0fc0..cb0b57dc73832332549b009de67c8d274da2c2d6 100644 (file)
@@ -62,10 +62,8 @@ fail:
 
 #define _check_numbers_template(arg_fmt, expect, str, fmt, n_args, ap)         \
 do {                                                                           \
-       pr_debug("\"%s\", \"%s\" ->\n", str, fmt);                              \
        for (; n_args > 0; n_args--, expect++) {                                \
                typeof(*expect) got = *va_arg(ap, typeof(expect));              \
-               pr_debug("\t" arg_fmt "\n", got);                               \
                if (got != *expect) {                                           \
                        pr_warn("%s:%d, vsscanf(\"%s\", \"%s\", ...) expected " arg_fmt " got " arg_fmt "\n", \
                                file, line, str, fmt, *expect, got);            \
@@ -689,7 +687,6 @@ do {                                                                                \
        total_tests++;                                                          \
        len = snprintf(test_buffer, BUF_SIZE, gen_fmt, expect);                 \
        got = (fn)(test_buffer, &endp, base);                                   \
-       pr_debug(#fn "(\"%s\", %d) -> " gen_fmt "\n", test_buffer, base, got);  \
        if (got != (expect)) {                                                  \
                fail = true;                                                    \
                pr_warn(#fn "(\"%s\", %d): got " gen_fmt " expected " gen_fmt "\n", \