Skip to content

Commit 890c6ba

Browse files
Update src/offlinelogstorage/dlt_offline_logstorage_behavior.c
Co-authored-by: Copilot <[email protected]>
1 parent 5e471e1 commit 890c6ba

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/offlinelogstorage/dlt_offline_logstorage_behavior.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,19 +1107,17 @@ int dlt_logstorage_prepare_on_msg(DltLogStorageFilterConfig *config,
11071107
/* Sync only if on_msg */
11081108
if ((config->sync == DLT_LOGSTORAGE_SYNC_ON_MSG) ||
11091109
(config->sync == DLT_LOGSTORAGE_SYNC_UNSET)) {
1110-
if (config->gzip_compression == DLT_LOGSTORAGE_GZIP_ON) {
1111-
if (fsync(fileno(config->gzlog)) != 0) {
1112-
if (errno != ENOSYS) {
1110+
if ((config->gzip_compression == DLT_LOGSTORAGE_GZIP_ON) &&
1111+
(fsync(fileno(config->gzlog)) != 0) &&
1112+
(errno != ENOSYS)) {
11131113
dlt_vlog(LOG_ERR, "%s: failed to sync gzip log file\n", __func__);
1114-
}
1115-
}
11161114
}
1117-
else {
1118-
if (fsync(config->fd) != 0) {
1119-
if (errno != ENOSYS) {
1115+
else if ((config->fd != -1) &&
1116+
(fsync(config->fd) != 0) &&
1117+
(errno != ENOSYS)) {
11201118
dlt_vlog(LOG_ERR, "%s: failed to sync log file\n", __func__);
1121-
}
1122-
}
1119+
} else {
1120+
dlt_vlog(LOG_ERR, "%s: invalid file descriptor for log file sync\n", __func__);
11231121
}
11241122
}
11251123

0 commit comments

Comments
 (0)