Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [bug report] pidfd: add polling selftests
@ 2019-06-12  9:52 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-06-12  9:52 UTC (permalink / raw)
  To: joel; +Cc: linux-kselftest

Hello Joel Fernandes (Google),

The patch 233ad92edbea: "pidfd: add polling selftests" from Apr 30,
2019, leads to the following static checker warning:

	./tools/testing/selftests/pidfd/pidfd_test.c:522 test_pidfd_poll_leader_exit()
	error: uninitialized symbol 'ret'.

./tools/testing/selftests/pidfd/pidfd_test.c
   485  static void test_pidfd_poll_leader_exit(int use_waitpid)
   486  {
   487          int pid, pidfd = 0;
   488          int status, ret;
   489          time_t prog_start = time(NULL);
   490          const char *test_name = "pidfd_poll check for premature notification on non-empty"
   491                                  "group leader exit";
   492  
   493          child_exit_secs = mmap(NULL, sizeof *child_exit_secs, PROT_READ | PROT_WRITE,
   494                          MAP_SHARED | MAP_ANONYMOUS, -1, 0);
   495  
   496          if (child_exit_secs == MAP_FAILED)
   497                  ksft_exit_fail_msg("%s test: mmap failed (errno %d)\n",
   498                                     test_name, errno);
   499  
   500          ksft_print_msg("Parent: pid: %d\n", getpid());
   501          pid = pidfd_clone(CLONE_PIDFD, &pidfd, child_poll_leader_exit_test);
   502          if (pid < 0)
   503                  ksft_exit_fail_msg("%s test: pidfd_clone failed (ret %d, errno %d)\n",
   504                                     test_name, pid, errno);
   505  
   506          ksft_print_msg("Parent: Waiting for Child (%d) to complete.\n", pid);
   507  
   508          if (use_waitpid) {
   509                  ret = waitpid(pid, &status, 0);
   510                  if (ret == -1)
   511                          ksft_print_msg("Parent: error\n");
   512          } else {
   513                  /*
   514                   * This sleep tests for the case where if the child exits, and is in
   515                   * EXIT_ZOMBIE, but the thread group leader is non-empty, then the poll
   516                   * doesn't prematurely return even though there are active threads
   517                   */
   518                  sleep(1);
   519                  poll_pidfd(test_name, pidfd);

"ret" is not initialized on this path.

   520          }
   521  
   522          if (ret == pid)
                    ^^^
   523                  ksft_print_msg("Parent: Child process waited for.\n");
   524  
   525          time_t since_child_exit = time(NULL) - *child_exit_secs;
   526  
   527          ksft_print_msg("Time since child exit: %lu\n", since_child_exit);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-06-12  9:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-12  9:52 [bug report] pidfd: add polling selftests Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox