X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fsyscall.c;h=7d0a92b6b1376ced33f150fa677cf25b4c0d9315;hp=6ee38bd0fa27a3f51c5541f8601a890d130b8aed;hb=6e2cc8d8a8193add85668d81385693f5fd662725;hpb=32af2c95c9494c282804964aed17bb2d57887505 diff --git a/src/bin/lttng-sessiond/syscall.c b/src/bin/lttng-sessiond/syscall.c index 6ee38bd0f..7d0a92b6b 100644 --- a/src/bin/lttng-sessiond/syscall.c +++ b/src/bin/lttng-sessiond/syscall.c @@ -16,6 +16,8 @@ */ #define _LGPL_SOURCE +#include + #include #include #include @@ -43,7 +45,8 @@ int syscall_init_table(void) size_t nbmem; FILE *fp; /* Syscall data from the kernel. */ - size_t index; + size_t index = 0; + bool at_least_one_syscall = false; uint32_t bitness; char name[SYSCALL_NAME_LEN]; @@ -76,12 +79,13 @@ int syscall_init_table(void) name = %" XSTR(SYSCALL_NAME_LEN) "[^;]; \ bitness = %u; };\n", &index, name, &bitness) == 3) { - if (index >= nbmem ) { + at_least_one_syscall = true; + if (index >= nbmem) { struct syscall *new_list; size_t new_nbmem; /* Double memory size. */ - new_nbmem = max(index, nbmem << 1); + new_nbmem = max(index + 1, nbmem << 1); if (new_nbmem > (SIZE_MAX / sizeof(*new_list))) { /* Overflow, stop everything, something went really wrong. */ ERR("Syscall listing memory size overflow. Stopping"); @@ -123,7 +127,10 @@ int syscall_init_table(void) */ } - syscall_table_nb_entry = index; + /* Index starts at 0. */ + if (at_least_one_syscall) { + syscall_table_nb_entry = index + 1; + } ret = 0;