X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=tests%2Fust-basic-tracing%2Fust-basic-tracing.c;h=e9b9ea6d17a5697e640d5ae7f3a18bdb1ba9effd;hb=fb31eb73d8a4a6d9784ed5c335b7fa3b9684108c;hp=cc0fb89b65721fb9fb4329cdae07e2c23b74a604;hpb=ee7fcec8c059c5b203d6aa5df7ceef414a55505c;p=lttng-ust.git diff --git a/tests/ust-basic-tracing/ust-basic-tracing.c b/tests/ust-basic-tracing/ust-basic-tracing.c index cc0fb89b..e9b9ea6d 100644 --- a/tests/ust-basic-tracing/ust-basic-tracing.c +++ b/tests/ust-basic-tracing/ust-basic-tracing.c @@ -20,24 +20,25 @@ #define _LARGEFILE64_SOURCE #define _GNU_SOURCE +#include #include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include #include #include -#include -#include #include #include @@ -647,7 +648,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, @@ -717,6 +722,7 @@ int main(int argc, const char **argv) const char *outputpath; const char **event_names; unsigned int nr_events; + long page_size; if (argc < 2) { printf("Usage:\n"); @@ -759,6 +765,15 @@ int main(int argc, const 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) { @@ -766,7 +781,7 @@ int main(int argc, const 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; @@ -792,7 +807,7 @@ int main(int argc, const 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;