clang-tidy: add Chrome-inspired checks
[lttng-tools.git] / tests / regression / kernel / select_poll_epoll.cpp
index 225855ef747f18aa8ceb231009f15e403de4e0a7..f4e947497123b7b5c8e02a32230ad8035e7df095 100644 (file)
@@ -92,7 +92,7 @@ struct ppoll_thread_data {
 };
 } /* namespace */
 
-static void test_select_big(void)
+static void test_select_big()
 {
        fd_set rfds, wfds, exfds;
        struct timeval tv;
@@ -117,7 +117,7 @@ static void test_select_big(void)
        if (timeout > 0) {
                ret = select(fd2 + 1, &rfds, &wfds, &exfds, &tv);
        } else {
-               ret = select(fd2 + 1, &rfds, &wfds, &exfds, NULL);
+               ret = select(fd2 + 1, &rfds, &wfds, &exfds, nullptr);
        }
 
        if (ret == -1) {
@@ -138,7 +138,7 @@ end:
        return;
 }
 
-static void test_pselect(void)
+static void test_pselect()
 {
        fd_set rfds;
        struct timespec tv;
@@ -152,9 +152,9 @@ static void test_pselect(void)
        tv.tv_nsec = timeout * MSEC_PER_NSEC;
 
        if (timeout > 0) {
-               ret = pselect(1, &rfds, NULL, NULL, &tv, NULL);
+               ret = pselect(1, &rfds, nullptr, nullptr, &tv, nullptr);
        } else {
-               ret = pselect(1, &rfds, NULL, NULL, NULL, NULL);
+               ret = pselect(1, &rfds, nullptr, nullptr, nullptr, nullptr);
        }
 
        if (ret == -1) {
@@ -167,7 +167,7 @@ static void test_pselect(void)
        }
 }
 
-static void test_select(void)
+static void test_select()
 {
        fd_set rfds;
        struct timeval tv;
@@ -181,9 +181,9 @@ static void test_select(void)
        tv.tv_usec = timeout * MSEC_PER_USEC;
 
        if (timeout > 0) {
-               ret = select(1, &rfds, NULL, NULL, &tv);
+               ret = select(1, &rfds, nullptr, nullptr, &tv);
        } else {
-               ret = select(1, &rfds, NULL, NULL, NULL);
+               ret = select(1, &rfds, nullptr, nullptr, nullptr);
        }
 
        if (ret == -1) {
@@ -196,7 +196,7 @@ static void test_select(void)
        }
 }
 
-static void test_poll(void)
+static void test_poll()
 {
        struct pollfd ufds[NB_FD];
        char buf[BUF_SIZE];
@@ -217,7 +217,7 @@ static void test_poll(void)
        }
 }
 
-static void test_ppoll(void)
+static void test_ppoll()
 {
        struct pollfd ufds[NB_FD];
        char buf[BUF_SIZE];
@@ -230,9 +230,9 @@ static void test_ppoll(void)
        if (timeout > 0) {
                ts.tv_sec = 0;
                ts.tv_nsec = timeout * MSEC_PER_NSEC;
-               ret = ppoll(ufds, 1, &ts, NULL);
+               ret = ppoll(ufds, 1, &ts, nullptr);
        } else {
-               ret = ppoll(ufds, 1, NULL, NULL);
+               ret = ppoll(ufds, 1, nullptr, nullptr);
        }
 
        if (ret < 0) {
@@ -260,7 +260,7 @@ static void test_ppoll_big(FILE *validation_output_file __attribute__((unused)))
                ufds[i].events = POLLIN | POLLPRI;
        }
 
-       ret = ppoll(ufds, MAX_FDS, NULL, NULL);
+       ret = ppoll(ufds, MAX_FDS, nullptr, nullptr);
 
        if (ret < 0) {
                PERROR("ppoll");
@@ -358,9 +358,9 @@ static void test_epoll_pwait(FILE *validation_output_file)
        }
 
        if (timeout > 0) {
-               ret = epoll_pwait(epollfd, &epoll_event, 1, timeout, NULL);
+               ret = epoll_pwait(epollfd, &epoll_event, 1, timeout, nullptr);
        } else {
-               ret = epoll_pwait(epollfd, &epoll_event, 1, -1, NULL);
+               ret = epoll_pwait(epollfd, &epoll_event, 1, -1, nullptr);
        }
 
        if (ret == 1) {
@@ -665,7 +665,7 @@ static void *ppoll_writer(void *arg)
                usleep(100);
        }
 
-       return NULL;
+       return nullptr;
 }
 
 static void do_ppoll(int *fds, struct pollfd *ufds)
@@ -682,7 +682,7 @@ static void do_ppoll(int *fds, struct pollfd *ufds)
                ufds[i].events = POLLIN | POLLPRI;
        }
 
-       ret = ppoll(ufds, MAX_FDS, &ts, NULL);
+       ret = ppoll(ufds, MAX_FDS, &ts, nullptr);
 
        if (ret < 0) {
                PERROR("ppoll");
@@ -705,7 +705,7 @@ static void stress_ppoll(int *fds, int value)
        thread_data.value = value;
 
        stop_thread = 0;
-       ret = pthread_create(&writer, NULL, &ppoll_writer, (void *) &thread_data);
+       ret = pthread_create(&writer, nullptr, &ppoll_writer, (void *) &thread_data);
        if (ret != 0) {
                fprintf(stderr, "[error] pthread_create\n");
                goto end;
@@ -714,7 +714,7 @@ static void stress_ppoll(int *fds, int value)
                do_ppoll(fds, ufds);
        }
        stop_thread = 1;
-       ret = pthread_join(writer, NULL);
+       ret = pthread_join(writer, nullptr);
        if (ret) {
                fprintf(stderr, "[error] pthread_join\n");
                goto end;
@@ -762,14 +762,14 @@ static void ppoll_concurrent_write(FILE *validation_output_file __attribute__((u
 
 static void *epoll_pwait_writer(void *addr)
 {
-       srand(time(NULL));
+       srand(time(nullptr));
 
        while (!stop_thread) {
                usleep(rand() % 30);
                munmap(addr, MAX_FDS * sizeof(struct epoll_event));
        }
 
-       return NULL;
+       return nullptr;
 }
 
 /*
@@ -800,7 +800,7 @@ static void epoll_pwait_concurrent_munmap(FILE *validation_output_file)
                goto error;
        }
 
-       epoll_event = (struct epoll_event *) mmap(NULL,
+       epoll_event = (struct epoll_event *) mmap(nullptr,
                                                  MAX_FDS * sizeof(struct epoll_event),
                                                  PROT_READ | PROT_WRITE,
                                                  MAP_PRIVATE | MAP_ANONYMOUS,
@@ -825,13 +825,13 @@ static void epoll_pwait_concurrent_munmap(FILE *validation_output_file)
                }
        }
        stop_thread = 0;
-       ret = pthread_create(&writer, NULL, &epoll_pwait_writer, (void *) epoll_event);
+       ret = pthread_create(&writer, nullptr, &epoll_pwait_writer, (void *) epoll_event);
        if (ret != 0) {
                fprintf(stderr, "[error] pthread_create\n");
                goto error_unmap;
        }
 
-       ret = epoll_pwait(epollfd, epoll_event, 1, 1, NULL);
+       ret = epoll_pwait(epollfd, epoll_event, 1, 1, nullptr);
 
        if (ret == 1) {
                ret = read(wait_fd, buf, BUF_SIZE);
@@ -843,7 +843,7 @@ static void epoll_pwait_concurrent_munmap(FILE *validation_output_file)
        }
 
        stop_thread = 1;
-       ret = pthread_join(writer, NULL);
+       ret = pthread_join(writer, nullptr);
        if (ret) {
                fprintf(stderr, "[error] pthread_join\n");
                goto error_unmap;
@@ -870,7 +870,7 @@ end:
        return;
 }
 
-static void print_list(void)
+static void print_list()
 {
        fprintf(stderr, "Test list (-t X):\n");
        fprintf(stderr,
@@ -909,23 +909,23 @@ int main(int argc, const char **argv)
        int c, ret, test = -1;
        poptContext optCon;
        struct rlimit open_lim;
-       FILE *test_validation_output_file = NULL;
-       const char *test_validation_output_file_path = NULL;
+       FILE *test_validation_output_file = nullptr;
+       const char *test_validation_output_file_path = nullptr;
        struct poptOption optionsTable[] = {
-               { "test", 't', POPT_ARG_INT, &test, 0, "Test to run", NULL },
-               { "list", 'l', 0, 0, 'l', "List of tests (-t X)", NULL },
+               { "test", 't', POPT_ARG_INT, &test, 0, "Test to run", nullptr },
+               { "list", 'l', 0, nullptr, 'l', "List of tests (-t X)", nullptr },
                { "validation-file",
                  'o',
                  POPT_ARG_STRING,
                  &test_validation_output_file_path,
                  0,
                  "Test case output",
-                 NULL },
-               POPT_AUTOHELP{ NULL, 0, 0, NULL, 0, NULL, NULL }
+                 nullptr },
+               POPT_AUTOHELP{ nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
        };
        const struct test_case *test_case;
 
-       optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
+       optCon = poptGetContext(nullptr, argc, argv, optionsTable, 0);
 
        if (argc < 2) {
                poptPrintUsage(optCon, stderr, 0);
@@ -971,7 +971,7 @@ int main(int argc, const char **argv)
         * for the validation, disabling the buffering on the validation file
         * works.
         */
-       setbuf(test_validation_output_file, NULL);
+       setbuf(test_validation_output_file, nullptr);
        wait_fd = STDIN_FILENO;
 
        /* Test case id is 1-based. */
This page took 0.026951 seconds and 4 git commands to generate.