Fix: handle sysconf errors
[lttng-ust.git] / tests / ust-multi-test / ust-multi-test.c
index 015211c97357b97ce6dd349d84fb8457bcc62c9d..7771154014376b79b92ae063601355fd3113ee51 100644 (file)
@@ -40,6 +40,7 @@
 #include <sys/socket.h>
 
 #include <ust-comm.h>
+#include <lttng/ust-error.h>
 #include <../../libringbuffer/backend.h>
 #include <../../libringbuffer/frontend.h>
 #include "../../liblttng-ust/compat.h" /* For ENODATA */
@@ -109,7 +110,7 @@ int open_streams(int sock, int channel_handle, struct lttng_ust_object_data *str
                        }
                        k++;
                }
-               if (ret == -ENOENT)
+               if (ret == -LTTNG_UST_ERR_NOENT)
                        break;
                if (ret)
                        return ret;
@@ -637,11 +638,15 @@ error:
 
 int update_futex(int fd, int active)
 {
-       size_t mmap_size = sysconf(_SC_PAGE_SIZE);
+       long page_size;
        char *wait_shm_mmap;
        int ret;
 
-       wait_shm_mmap = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,
+       page_size = sysconf(_SC_PAGE_SIZE);
+       if (page_size < 0) {
+               goto error;
+       }
+       wait_shm_mmap = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
                  MAP_SHARED, fd, 0);
        if (wait_shm_mmap == MAP_FAILED) {
                perror("mmap");
@@ -655,7 +660,7 @@ int update_futex(int fd, int active)
        } else {
                uatomic_set((int32_t *) wait_shm_mmap, 0);
        }
-       ret = munmap(wait_shm_mmap, mmap_size);
+       ret = munmap(wait_shm_mmap, page_size);
        if (ret) {
                perror("Error unmapping wait shm");
                goto error;
@@ -813,6 +818,7 @@ int main(int argc, char **argv)
                        pid_t ppid;
                        uid_t uid;
                        gid_t gid;
+                       uint32_t bits_per_long;
                        char name[16];  /* Process name */
                } reg_msg;
                char bufname[17];
@@ -870,6 +876,7 @@ end:
                ret = system(cmd);
                if (ret < 0) {
                        printf("Unable to clean %s\n", home_rundir);
+                       return -1;
                }
        }
 
This page took 0.023529 seconds and 4 git commands to generate.