Cleanup: apply `include-what-you-use` guideline for `uint*_t`
[lttng-ust.git] / tests / ust-multi-test / ust-multi-test.c
index c003c5a93f0f00bf033be2a54cccd7015b7996f5..eb047655ac68402b89be269f4834728e1a7c6186 100644 (file)
 
 #define _LARGEFILE64_SOURCE
 #define _GNU_SOURCE
+#include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <sys/time.h>
+#include <sys/mman.h>
 #include <sys/resource.h>
+#include <sys/socket.h>
 #include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <limits.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
 #include <urcu/futex.h>
 #include <urcu/uatomic.h>
-#include <assert.h>
-#include <sys/socket.h>
 
 #include <ust-comm.h>
 #include <lttng/ust-error.h>
@@ -643,7 +644,11 @@ int update_futex(int fd, int active)
        int ret;
 
        page_size = sysconf(_SC_PAGE_SIZE);
-       if (page_size < 0) {
+       if (page_size <= 0) {
+               if (!page_size) {
+                       errno = EINVAL;
+               }
+               perror("Error in sysconf(_SC_PAGE_SIZE)");
                goto error;
        }
        wait_shm_mmap = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
@@ -706,6 +711,7 @@ int main(int argc, char **argv)
        int ret, wait_shm_fd;
        struct sigaction act;
        mode_t old_umask = 0;
+       long page_size;
 
        set_ulimit();
 
@@ -738,6 +744,15 @@ int main(int argc, char **argv)
                return -1;
        }
 
+       page_size = sysconf(_SC_PAGE_SIZE);
+       if (page_size <= 0) {
+               if (!page_size) {
+                       errno = EINVAL;
+               }
+               perror("Error in sysconf(_SC_PAGE_SIZE)");
+               return -1;
+       }
+
        if (geteuid() == 0) {
                ret = mkdir(LTTNG_RUNDIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
                if (ret && errno != EEXIST) {
@@ -745,7 +760,7 @@ int main(int argc, char **argv)
                        return -1;
                }
                wait_shm_fd = get_wait_shm(DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH,
-                                       sysconf(_SC_PAGE_SIZE), 1);
+                                       page_size, 1);
                if (wait_shm_fd < 0) {
                        perror("global wait shm error");
                        return -1;
@@ -771,7 +786,7 @@ int main(int argc, char **argv)
                snprintf(local_apps_wait_shm_path, PATH_MAX,
                         DEFAULT_HOME_APPS_WAIT_SHM_PATH, getuid());
                wait_shm_fd = get_wait_shm(local_apps_wait_shm_path,
-                                       sysconf(_SC_PAGE_SIZE), 0);
+                                       page_size, 0);
                if (wait_shm_fd < 0) {
                        perror("local wait shm error");
                        return -1;
This page took 0.023713 seconds and 4 git commands to generate.