From b049b408f7b15ef5ecdc71723812f43161d25ce8 Mon Sep 17 00:00:00 2001 From: Saya Sugiura Date: Mon, 4 Feb 2019 16:57:15 +0900 Subject: Logstorage: Fix write msg cache When the message is just fitting to the remaining cache, it is ignored and goes to the head. This commit fixes to add the message to the end. Signed-off-by: Saya Sugiura --- src/offlinelogstorage/dlt_offline_logstorage_behavior.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index 1d31f46..5d9576b 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -821,7 +821,7 @@ int dlt_logstorage_prepare_on_msg(DltLogStorageFilterConfig *config, if (ret == 0) { /* check if adding new data do not exceed max file size */ - if (s.st_size + log_msg_size >= (int)config->file_size) { + if (s.st_size + log_msg_size > (int)config->file_size) { fclose(config->log); config->log = NULL; ret = dlt_logstorage_open_log_file(config, @@ -1090,7 +1090,7 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config, remain_cache_size = config->file_size - footer->offset; } - if (msg_size < remain_cache_size) { /* add at current position */ + if (msg_size <= remain_cache_size) { /* add at current position */ curr_write_addr = (void *)(config->cache + footer->offset); footer->offset += msg_size; } @@ -1152,10 +1152,6 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config, footer->offset = msg_size; footer->wrap_around_cnt += 1; } - else { /* message just fits into cache */ - curr_write_addr = (void *)(config->cache + footer->offset); - footer->wrap_around_cnt += 1; - } /* write data to cache */ memcpy(curr_write_addr, data1, size1); -- cgit v1.2.1