All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: joel@joelfernandes.org
Cc: linux-kselftest@vger.kernel.org
Subject: [bug report] pidfd: add polling selftests
Date: Wed, 12 Jun 2019 12:52:25 +0300	[thread overview]
Message-ID: <20190612095225.GA14303@mwanda> (raw)

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

                 reply	other threads:[~2019-06-12  9:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190612095225.GA14303@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kselftest@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.