From 7735f715b7025f5222110266c4213b85e74baf92 Mon Sep 17 00:00:00 2001 From: gustav Date: Tue, 29 Oct 2024 07:28:46 +0100 Subject: [PATCH 1/3] Fix compiler warnings related to signs Fix signedness of some variables so the compiler flags sign-compare and pointer-sign can be enabled. This doesn't change any behaviour nor fix any bugs. It is just to be able to run the compiler with those flags so future bugs can be avoided. --- src/daemon/dlt-daemon.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 884338b52..f0d5a1657 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -2221,7 +2221,7 @@ static char* file_read_everything(FILE* const file, const size_t sizeLimit) /* Size limit includes NULL terminator. */ const off_t size = s_buf.st_size; - if (size < 0 || size >= sizeLimit) { + if (size < 0 || (size_t)size >= sizeLimit) { dlt_log(LOG_WARNING, "file size invalid\n"); fclose(file); return NULL; @@ -2270,7 +2270,7 @@ static char* file_read_field(FILE* const file, const char* const fieldName) char* result = NULL; char* buffer = NULL; - ssize_t bufferSize = 0; + size_t bufferSize = 0; while (true) { ssize_t lineSize = getline(&buffer, &bufferSize, file); @@ -2288,10 +2288,9 @@ static char* file_read_field(FILE* const file, const char* const fieldName) } /* check fieldName */ - if ( strncmp(line, fieldName, fieldNameLen) == 0 - && lineSize >= (fieldNameLen + 1) - && strchr(kDelimiters, line[fieldNameLen]) != NULL - ) { + if (strncmp(line, fieldName, fieldNameLen) == 0 && + (size_t)lineSize >= (fieldNameLen + 1) && + strchr(kDelimiters, line[fieldNameLen]) != NULL) { /* trim fieldName */ line += fieldNameLen; From a6e343a26e08b241ab3b8b4affaa87c08e6ef5a8 Mon Sep 17 00:00:00 2001 From: gustav Date: Thu, 31 Oct 2024 12:14:49 +0100 Subject: [PATCH 2/3] Remove free of string litteral To use free on memory not assigned by alloc is undefined behavior and could cause bugs in some systems. Also move assignment out of for loop. --- .../dlt_offline_logstorage_behavior.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index fb9c95f2f..dc5f67941 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -370,15 +370,9 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, config->records = NULL; } - char* suffix = NULL; - for (i = 0; i < cnt; i++) { - if (config->gzip_compression) { - suffix = strdup(".dlt.gz"); - } - else { - suffix = strdup(".dlt"); - } + char *suffix = config->gzip_compression ? ".dlt.gz" : ".dlt"; + for (i = 0; i < cnt; i++) { int len = 0; len = strlen(file_name); @@ -470,11 +464,6 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, free(files); - if (suffix) { - free(suffix); - suffix = NULL; - } - return ret; } From d43ca8b212775fc32d893efc77a83e984639cdd4 Mon Sep 17 00:00:00 2001 From: gustav Date: Wed, 6 Nov 2024 07:04:59 +0100 Subject: [PATCH 3/3] Update documentation on offline storage required parts --- doc/dlt_offline_logstorage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dlt_offline_logstorage.md b/doc/dlt_offline_logstorage.md index 1bb3d1867..e2346e5b2 100644 --- a/doc/dlt_offline_logstorage.md +++ b/doc/dlt_offline_logstorage.md @@ -82,7 +82,7 @@ OverwriteBehavior= # Specify overwrite strategy. Default: Dele DisableNetwork= # Specify if the message shall be routed to network client. ``` -The Parameter "SyncBehavior", "OverwriteBehavior", "DisableNetwork", "EcuID" and +The Parameters "SyncBehavior", "GzipCompression", "OverwriteBehavior", "DisableNetwork", "EcuID" and "SpecificSize" are optional - all others are mandatory. If both of the parameter "LogAppName" and "ContextName" are set to wildcard or