From 676e8fc1ba927dc84df82b508d796e31d9fd120c Mon Sep 17 00:00:00 2001 From: Felix Herrmann Date: Mon, 13 Jan 2020 10:40:25 +0100 Subject: 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 Signed-off-by: KHANH LUONG HONG DUY --- src/daemon/dlt_daemon_common.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/daemon/dlt_daemon_common.c') 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); } } -- cgit v1.2.1