diff options
author | Felix Herrmann <fherrmann@de.adit-jv.com> | 2020-01-13 10:40:25 +0100 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2020-07-06 10:04:07 +0900 |
commit | 676e8fc1ba927dc84df82b508d796e31d9fd120c (patch) | |
tree | 141271d339f1ba68d0b29fd124e8eaa5d3d99fd4 /src/daemon/dlt_daemon_common.c | |
parent | ec391decd94ac9f6c6133c24a41c8afb2c01623f (diff) | |
download | DLT-daemon-676e8fc1ba927dc84df82b508d796e31d9fd120c.tar.gz |
fix some gcc9 compiler warnings
Many stringop-truncation and stringop-overflow warnings are still
there (so many).
https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/
Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com>
Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
Diffstat (limited to 'src/daemon/dlt_daemon_common.c')
-rw-r--r-- | src/daemon/dlt_daemon_common.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index 195c55f..d96d8f2 100644 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -481,12 +481,8 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon, application->application_description = malloc(strlen(description) + 1); if (application->application_description) { - strncpy(application->application_description, - description, - strlen(description)); - application->application_description[strlen(description)] = '\0'; - } - else { + memcpy(application->application_description, description, strlen(description) + 1); + } else { dlt_log(LOG_ERR, "Cannot allocate memory to store application description\n"); free(application); return (DltDaemonApplication *)NULL; @@ -874,8 +870,7 @@ DltDaemonContext *dlt_daemon_context_add(DltDaemon *daemon, context->context_description = malloc(strlen(description) + 1); if (context->context_description) { - strncpy(context->context_description, description, strlen(description)); - context->context_description[strlen(description)] = '\0'; + memcpy(context->context_description, description, strlen(description) + 1); } } |