/* The process_mrelease calls in this test are expected to fail */
 static void run_negative_tests(int pidfd)
 {
+       int res;
        /* Test invalid flags. Expect to fail with EINVAL error code. */
        if (!syscall(__NR_process_mrelease, pidfd, (unsigned int)-1) ||
                        errno != EINVAL) {
+               res = (errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
                perror("process_mrelease with wrong flags");
-               exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
+               exit(res);
        }
        /*
         * Test reaping while process is alive with no pending SIGKILL.
         * Expect to fail with EINVAL error code.
         */
        if (!syscall(__NR_process_mrelease, pidfd, 0) || errno != EINVAL) {
+               res = (errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
                perror("process_mrelease on a live process");
-               exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
+               exit(res);
        }
 }
 
 
        /* Test a wrong pidfd */
        if (!syscall(__NR_process_mrelease, -1, 0) || errno != EBADF) {
+               res = (errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
                perror("process_mrelease with wrong pidfd");
-               exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
+               exit(res);
        }
 
        /* Start the test with 1MB child memory allocation */
        run_negative_tests(pidfd);
 
        if (kill(pid, SIGKILL)) {
+               res = (errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
                perror("kill");
-               exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
+               exit(res);
        }
 
        success = (syscall(__NR_process_mrelease, pidfd, 0) == 0);
                if (errno == ESRCH) {
                        retry = (size <= MAX_SIZE_MB);
                } else {
+                       res = (errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
                        perror("process_mrelease");
                        waitpid(pid, NULL, 0);
-                       exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
+                       exit(res);
                }
        }