Skip to content

Commit 4d7f4e8

Browse files
maciejwieczorretmanshuahkh
authored andcommitted
selftests/pidfd: Fix ksft print formats
Compiling pidfd selftest after adding a __printf() attribute to ksft_print_msg() and ksft_test_result_pass() exposes -Wformat warnings in error_report(), test_pidfd_poll_exec_thread(), child_poll_exec_test(), test_pidfd_poll_leader_exit_thread(), child_poll_leader_exit_test(). The ksft_test_result_pass() in error_report() expects a string but doesn't provide any argument after the format string. All the other calls to ksft_print_msg() in the functions mentioned above have format strings that don't match with other passed arguments. Fix format specifiers so they match the passed variables. Add a missing variable to ksft_test_result_pass() inside error_report() so it matches other cases in the switch statement. Fixes: 2def297 ("pidfd: add tests for NSpid info in fdinfo") Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 287d298 commit 4d7f4e8

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

tools/testing/selftests/pidfd/pidfd_fdinfo_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void error_report(struct error *err, const char *test_name)
6262
break;
6363

6464
case PIDFD_PASS:
65-
ksft_test_result_pass("%s test: Passed\n");
65+
ksft_test_result_pass("%s test: Passed\n", test_name);
6666
break;
6767

6868
default:

tools/testing/selftests/pidfd/pidfd_test.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,13 @@ static int test_pidfd_send_signal_syscall_support(void)
381381

382382
static void *test_pidfd_poll_exec_thread(void *priv)
383383
{
384-
ksft_print_msg("Child Thread: starting. pid %d tid %d ; and sleeping\n",
384+
ksft_print_msg("Child Thread: starting. pid %d tid %ld ; and sleeping\n",
385385
getpid(), syscall(SYS_gettid));
386386
ksft_print_msg("Child Thread: doing exec of sleep\n");
387387

388388
execl("/bin/sleep", "sleep", str(CHILD_THREAD_MIN_WAIT), (char *)NULL);
389389

390-
ksft_print_msg("Child Thread: DONE. pid %d tid %d\n",
390+
ksft_print_msg("Child Thread: DONE. pid %d tid %ld\n",
391391
getpid(), syscall(SYS_gettid));
392392
return NULL;
393393
}
@@ -427,7 +427,7 @@ static int child_poll_exec_test(void *args)
427427
{
428428
pthread_t t1;
429429

430-
ksft_print_msg("Child (pidfd): starting. pid %d tid %d\n", getpid(),
430+
ksft_print_msg("Child (pidfd): starting. pid %d tid %ld\n", getpid(),
431431
syscall(SYS_gettid));
432432
pthread_create(&t1, NULL, test_pidfd_poll_exec_thread, NULL);
433433
/*
@@ -480,10 +480,10 @@ static void test_pidfd_poll_exec(int use_waitpid)
480480

481481
static void *test_pidfd_poll_leader_exit_thread(void *priv)
482482
{
483-
ksft_print_msg("Child Thread: starting. pid %d tid %d ; and sleeping\n",
483+
ksft_print_msg("Child Thread: starting. pid %d tid %ld ; and sleeping\n",
484484
getpid(), syscall(SYS_gettid));
485485
sleep(CHILD_THREAD_MIN_WAIT);
486-
ksft_print_msg("Child Thread: DONE. pid %d tid %d\n", getpid(), syscall(SYS_gettid));
486+
ksft_print_msg("Child Thread: DONE. pid %d tid %ld\n", getpid(), syscall(SYS_gettid));
487487
return NULL;
488488
}
489489

@@ -492,7 +492,7 @@ static int child_poll_leader_exit_test(void *args)
492492
{
493493
pthread_t t1, t2;
494494

495-
ksft_print_msg("Child: starting. pid %d tid %d\n", getpid(), syscall(SYS_gettid));
495+
ksft_print_msg("Child: starting. pid %d tid %ld\n", getpid(), syscall(SYS_gettid));
496496
pthread_create(&t1, NULL, test_pidfd_poll_leader_exit_thread, NULL);
497497
pthread_create(&t2, NULL, test_pidfd_poll_leader_exit_thread, NULL);
498498

0 commit comments

Comments
 (0)