diff options
author | Phong Tran <tranmanphong@gmail.com> | 2019-06-20 20:52:39 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2019-06-24 17:39:20 +0900 |
commit | 58264cc5dff50527598a0ef11d4a87a128960c9b (patch) | |
tree | 1d073f7d9b27720d25c9bdaf5144830d4e7990d1 /src | |
parent | d6bedbc8fce89dda50dfb73c168693f9d1ccf7fb (diff) | |
download | DLT-daemon-58264cc5dff50527598a0ef11d4a87a128960c9b.tar.gz |
fix the warning of strncat size
clang warns that
warning: size argument in 'strncat' call appears to be size of the
source [-Wstrncat-size]
strncat(log_file_name, file_index, sizeof(file_index));
^~~~~~~~~~~~~~~~~~
do as the
https://github.com/llvm-mirror/clang/blob/05be53c9524408516651d5678d55d0d4a5d3a894/test/Sema/warn-strncat-size.c#L30
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/dlt_offline_trace.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c index fd59fc0..8049495 100644 --- a/src/shared/dlt_offline_trace.c +++ b/src/shared/dlt_offline_trace.c @@ -147,10 +147,10 @@ void dlt_offline_trace_file_name(char *log_file_name, char *name, unsigned int i /* create log file name */ memset(log_file_name, 0, DLT_OFFLINETRACE_FILENAME_MAX_SIZE * sizeof(char)); - strncat(log_file_name, name, sizeof(DLT_OFFLINETRACE_FILENAME_BASE)); - strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_DELI, sizeof(DLT_OFFLINETRACE_FILENAME_DELI)); - strncat(log_file_name, file_index, sizeof(file_index)); - strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_EXT, sizeof(DLT_OFFLINETRACE_FILENAME_EXT)); + strncat(log_file_name, name, sizeof(log_file_name) - strlen(log_file_name) - 1); + strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_DELI, sizeof(log_file_name) - strlen(log_file_name) - 1); + strncat(log_file_name, file_index, sizeof(log_file_name) - strlen(log_file_name) - 1); + strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_EXT, sizeof(log_file_name) - strlen(log_file_name) - 1); } unsigned int dlt_offline_trace_get_idx_of_log_file(char *file) |