selftests:modify the incorrect print format
authorzhujun2 <zhujun2@cmss.chinamobile.com>
Tue, 17 Oct 2023 02:08:56 +0000 (19:08 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 18 Oct 2023 20:33:44 +0000 (14:33 -0600)
when the argument type is 'unsigned int',printf '%u'
in format string. Problem found during code reading.

Update commit log with information on how the problem
was found:
Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: zhujun2 <zhujun2@cmss.chinamobile.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/kselftest.h

index 5696199c16f935dc47757f344cd0ef27e22229cc..a781e6311810bfabf78c9b950b91ca1371314c1f 100644 (file)
@@ -132,7 +132,7 @@ static inline void ksft_print_header(void)
 static inline void ksft_set_plan(unsigned int plan)
 {
        ksft_plan = plan;
-       printf("1..%d\n", ksft_plan);
+       printf("1..%u\n", ksft_plan);
 }
 
 static inline void ksft_print_cnts(void)
@@ -140,7 +140,7 @@ static inline void ksft_print_cnts(void)
        if (ksft_plan != ksft_test_num())
                printf("# Planned tests != run tests (%u != %u)\n",
                        ksft_plan, ksft_test_num());
-       printf("# Totals: pass:%d fail:%d xfail:%d xpass:%d skip:%d error:%d\n",
+       printf("# Totals: pass:%u fail:%u xfail:%u xpass:%u skip:%u error:%u\n",
                ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
                ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
                ksft_cnt.ksft_xskip, ksft_cnt.ksft_error);
@@ -179,7 +179,7 @@ static inline __printf(1, 2) void ksft_test_result_pass(const char *msg, ...)
        ksft_cnt.ksft_pass++;
 
        va_start(args, msg);
-       printf("ok %d ", ksft_test_num());
+       printf("ok %u ", ksft_test_num());
        errno = saved_errno;
        vprintf(msg, args);
        va_end(args);
@@ -193,7 +193,7 @@ static inline __printf(1, 2) void ksft_test_result_fail(const char *msg, ...)
        ksft_cnt.ksft_fail++;
 
        va_start(args, msg);
-       printf("not ok %d ", ksft_test_num());
+       printf("not ok %u ", ksft_test_num());
        errno = saved_errno;
        vprintf(msg, args);
        va_end(args);
@@ -219,7 +219,7 @@ static inline __printf(1, 2) void ksft_test_result_xfail(const char *msg, ...)
        ksft_cnt.ksft_xfail++;
 
        va_start(args, msg);
-       printf("ok %d # XFAIL ", ksft_test_num());
+       printf("ok %u # XFAIL ", ksft_test_num());
        errno = saved_errno;
        vprintf(msg, args);
        va_end(args);
@@ -233,7 +233,7 @@ static inline __printf(1, 2) void ksft_test_result_skip(const char *msg, ...)
        ksft_cnt.ksft_xskip++;
 
        va_start(args, msg);
-       printf("ok %d # SKIP ", ksft_test_num());
+       printf("ok %u # SKIP ", ksft_test_num());
        errno = saved_errno;
        vprintf(msg, args);
        va_end(args);
@@ -248,7 +248,7 @@ static inline __printf(1, 2) void ksft_test_result_error(const char *msg, ...)
        ksft_cnt.ksft_error++;
 
        va_start(args, msg);
-       printf("not ok %d # error ", ksft_test_num());
+       printf("not ok %u # error ", ksft_test_num());
        errno = saved_errno;
        vprintf(msg, args);
        va_end(args);