[RESEND PATCH v2] selftests:Fix printf format string in kselftest_harness.h

Zhu Jun posted 1 patch 1 year, 6 months ago
There is a newer version of this series
tools/testing/selftests/kselftest_harness.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[RESEND PATCH v2] selftests:Fix printf format string in kselftest_harness.h
Posted by Zhu Jun 1 year, 6 months ago
'%u' in format string requires 'unsigned int' in __wait_for_test()
but the argument type is 'signed int' that this problem was discovered 
by reading code

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
Changes in v2:
 - modify commit info add how to find the problem in the log

 tools/testing/selftests/kselftest_harness.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index b634969cbb6f..dbbbcc6c04ee 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -1084,7 +1084,7 @@ void __wait_for_test(struct __test_metadata *t)
 		}
 	} else {
 		fprintf(TH_LOG_STREAM,
-			"# %s: Test ended in some other way [%u]\n",
+			"# %s: Test ended in some other way [%d]\n",
 			t->name,
 			status);
 	}
-- 
2.17.1
Re: [RESEND PATCH v2] selftests:Fix printf format string in kselftest_harness.h
Posted by Chunyan Zhang 1 year, 6 months ago
Hi Zhu Jun,

On Wed, 24 Jul 2024 at 10:15, Zhu Jun <zhujun2@cmss.chinamobile.com> wrote:
>
> '%u' in format string requires 'unsigned int' in __wait_for_test()
> but the argument type is 'signed int' that this problem was discovered
> by reading code
>
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
> Changes in v2:
>  - modify commit info add how to find the problem in the log
>
>  tools/testing/selftests/kselftest_harness.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index b634969cbb6f..dbbbcc6c04ee 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -1084,7 +1084,7 @@ void __wait_for_test(struct __test_metadata *t)
>                 }
>         } else {
>                 fprintf(TH_LOG_STREAM,
> -                       "# %s: Test ended in some other way [%u]\n",
> +                       "# %s: Test ended in some other way [%d]\n",
>                         t->name,
>                         status);

Seems this can use macro WTERMSIG like those above usage, rather than
changing the print format.

Thanks,
Chunyan