Skip to content

Commit ecc4185

Browse files
zhujun2shuahkh
authored andcommitted
selftests:modify the incorrect print format
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>
1 parent 3f6f8a8 commit ecc4185

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tools/testing/selftests/kselftest.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ static inline void ksft_print_header(void)
132132
static inline void ksft_set_plan(unsigned int plan)
133133
{
134134
ksft_plan = plan;
135-
printf("1..%d\n", ksft_plan);
135+
printf("1..%u\n", ksft_plan);
136136
}
137137

138138
static inline void ksft_print_cnts(void)
139139
{
140140
if (ksft_plan != ksft_test_num())
141141
printf("# Planned tests != run tests (%u != %u)\n",
142142
ksft_plan, ksft_test_num());
143-
printf("# Totals: pass:%d fail:%d xfail:%d xpass:%d skip:%d error:%d\n",
143+
printf("# Totals: pass:%u fail:%u xfail:%u xpass:%u skip:%u error:%u\n",
144144
ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
145145
ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
146146
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, ...)
179179
ksft_cnt.ksft_pass++;
180180

181181
va_start(args, msg);
182-
printf("ok %d ", ksft_test_num());
182+
printf("ok %u ", ksft_test_num());
183183
errno = saved_errno;
184184
vprintf(msg, args);
185185
va_end(args);
@@ -193,7 +193,7 @@ static inline __printf(1, 2) void ksft_test_result_fail(const char *msg, ...)
193193
ksft_cnt.ksft_fail++;
194194

195195
va_start(args, msg);
196-
printf("not ok %d ", ksft_test_num());
196+
printf("not ok %u ", ksft_test_num());
197197
errno = saved_errno;
198198
vprintf(msg, args);
199199
va_end(args);
@@ -219,7 +219,7 @@ static inline __printf(1, 2) void ksft_test_result_xfail(const char *msg, ...)
219219
ksft_cnt.ksft_xfail++;
220220

221221
va_start(args, msg);
222-
printf("ok %d # XFAIL ", ksft_test_num());
222+
printf("ok %u # XFAIL ", ksft_test_num());
223223
errno = saved_errno;
224224
vprintf(msg, args);
225225
va_end(args);
@@ -233,7 +233,7 @@ static inline __printf(1, 2) void ksft_test_result_skip(const char *msg, ...)
233233
ksft_cnt.ksft_xskip++;
234234

235235
va_start(args, msg);
236-
printf("ok %d # SKIP ", ksft_test_num());
236+
printf("ok %u # SKIP ", ksft_test_num());
237237
errno = saved_errno;
238238
vprintf(msg, args);
239239
va_end(args);
@@ -248,7 +248,7 @@ static inline __printf(1, 2) void ksft_test_result_error(const char *msg, ...)
248248
ksft_cnt.ksft_error++;
249249

250250
va_start(args, msg);
251-
printf("not ok %d # error ", ksft_test_num());
251+
printf("not ok %u # error ", ksft_test_num());
252252
errno = saved_errno;
253253
vprintf(msg, args);
254254
va_end(args);

0 commit comments

Comments
 (0)