From: Michael Jeanson Date: Mon, 5 Oct 2020 19:31:42 +0000 (-0400) Subject: fix: strncpy equals destination size warning X-Git-Tag: v2.13.0-rc1~162 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=092ffe9764a1f127a33dc8eed682f7cd5e81bed1;p=lttng-modules.git fix: strncpy equals destination size warning Some versions of GCC when called with -Wstringop-truncation will warn when doing a copy of the same size as the destination buffer with strncpy : ‘strncpy’ specified bound 256 equals destination size [-Werror=stringop-truncation] Since we unconditionally write '\0' in the last byte, reduce the copy size by one. Change-Id: Idb907c9550817a06fc0dffc489740f63d440e7d4 Signed-off-by: Mathieu Desnoyers Signed-off-by: Michael Jeanson --- diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 9a72245c..05284040 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -721,7 +721,7 @@ int fill_table(const struct trace_syscall_entry *table, size_t table_len, ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT; break; } - strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN); + strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN - 1); ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; ev.instrumentation = LTTNG_KERNEL_SYSCALL; chan_table[i] = _lttng_event_create(chan, &ev, filter,