Fix: handle sysconf possible negative returned value
authorDavid Goulet <dgoulet@efficios.com>
Wed, 1 Oct 2014 18:57:36 +0000 (14:57 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 1 Oct 2014 18:57:36 +0000 (14:57 -0400)
Fixes Coverity issue 1019947.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/shm.c

index 7bb52d4ee2feeb513d59079bf11813f319d8c48a..a5caa8bb6cdd3ab054872caedb86d362dd714d64 100644 (file)
@@ -132,12 +132,20 @@ error:
  */
 char *shm_ust_get_mmap(char *shm_path, int global)
 {
  */
 char *shm_ust_get_mmap(char *shm_path, int global)
 {
-       size_t mmap_size = sysconf(_SC_PAGE_SIZE);
+       size_t mmap_size;
        int wait_shm_fd, ret;
        char *wait_shm_mmap;
        int wait_shm_fd, ret;
        char *wait_shm_mmap;
+       long sys_page_size;
 
        assert(shm_path);
 
 
        assert(shm_path);
 
+       sys_page_size = sysconf(_SC_PAGE_SIZE);
+       if (sys_page_size < 0) {
+               PERROR("sysconf PAGE_SIZE");
+               goto error;
+       }
+       mmap_size = sys_page_size;
+
        wait_shm_fd = get_wait_shm(shm_path, mmap_size, global);
        if (wait_shm_fd < 0) {
                goto error;
        wait_shm_fd = get_wait_shm(shm_path, mmap_size, global);
        if (wait_shm_fd < 0) {
                goto error;
This page took 0.04135 seconds and 4 git commands to generate.