Skip to content

Commit e2aa5e6

Browse files
CmdrMoozyshuahkh
authored andcommitted
selftests: fixup build warnings in pidfd / clone3 tests
These are some trivial fixups, which were needed to build the tests with clang and -Werror. The following issues are fixed: - Remove various unused variables. - In child_poll_leader_exit_test, clang isn't smart enough to realize syscall(SYS_exit, 0) won't return, so it complains we never return from a non-void function. Add an extra exit(0) to appease it. - In test_pidfd_poll_leader_exit, ret may be branched on despite being uninitialized, if we have !use_waitpid. Initialize it to zero to get the right behavior in that case. Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> Acked-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 4cbd93c commit e2aa5e6

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

tools/testing/selftests/clone3/clone3.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ static void test_clone3(uint64_t flags, size_t size, int expected,
126126

127127
int main(int argc, char *argv[])
128128
{
129-
pid_t pid;
130-
131129
uid_t uid = getuid();
132130

133131
ksft_print_header();

tools/testing/selftests/pidfd/pidfd_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ static void test_pidfd_poll_exec(int use_waitpid)
441441
{
442442
int pid, pidfd = 0;
443443
int status, ret;
444-
pthread_t t1;
445444
time_t prog_start = time(NULL);
446445
const char *test_name = "pidfd_poll check for premature notification on child thread exec";
447446

@@ -500,13 +499,14 @@ static int child_poll_leader_exit_test(void *args)
500499
*/
501500
*child_exit_secs = time(NULL);
502501
syscall(SYS_exit, 0);
502+
/* Never reached, but appeases compiler thinking we should return. */
503+
exit(0);
503504
}
504505

505506
static void test_pidfd_poll_leader_exit(int use_waitpid)
506507
{
507508
int pid, pidfd = 0;
508-
int status, ret;
509-
time_t prog_start = time(NULL);
509+
int status, ret = 0;
510510
const char *test_name = "pidfd_poll check for premature notification on non-empty"
511511
"group leader exit";
512512

tools/testing/selftests/pidfd/pidfd_wait.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ static int sys_waitid(int which, pid_t pid, siginfo_t *info, int options,
3939

4040
TEST(wait_simple)
4141
{
42-
int pidfd = -1, status = 0;
42+
int pidfd = -1;
4343
pid_t parent_tid = -1;
4444
struct clone_args args = {
4545
.parent_tid = ptr_to_u64(&parent_tid),
4646
.pidfd = ptr_to_u64(&pidfd),
4747
.flags = CLONE_PIDFD | CLONE_PARENT_SETTID,
4848
.exit_signal = SIGCHLD,
4949
};
50-
int ret;
5150
pid_t pid;
5251
siginfo_t info = {
5352
.si_signo = 0,
@@ -88,7 +87,7 @@ TEST(wait_simple)
8887

8988
TEST(wait_states)
9089
{
91-
int pidfd = -1, status = 0;
90+
int pidfd = -1;
9291
pid_t parent_tid = -1;
9392
struct clone_args args = {
9493
.parent_tid = ptr_to_u64(&parent_tid),

0 commit comments

Comments
 (0)