Skip to content

Commit c4da3ef

Browse files
Update src/offlinelogstorage/dlt_offline_logstorage_behavior.c
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5e471e1 commit c4da3ef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/offlinelogstorage/dlt_offline_logstorage_behavior.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,10 +1115,14 @@ int dlt_logstorage_prepare_on_msg(DltLogStorageFilterConfig *config,
11151115
}
11161116
}
11171117
else {
1118-
if (fsync(config->fd) != 0) {
1119-
if (errno != ENOSYS) {
1120-
dlt_vlog(LOG_ERR, "%s: failed to sync log file\n", __func__);
1118+
if (config->fd != -1) {
1119+
if (fsync(config->fd) != 0) {
1120+
if (errno != ENOSYS) {
1121+
dlt_vlog(LOG_ERR, "%s: failed to sync log file\n", __func__);
1122+
}
11211123
}
1124+
} else {
1125+
dlt_vlog(LOG_ERR, "%s: invalid file descriptor for log file sync\n", __func__);
11221126
}
11231127
}
11241128
}

0 commit comments

Comments
 (0)