summaryrefslogtreecommitdiff
path: root/src/system
diff options
context:
space:
mode:
authorSebastian Kloska <sebastian.kloska@daimler.com>2019-09-12 16:29:34 +0200
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2019-09-13 11:56:51 +0900
commit50771881e91bc78ad01720ad78eaa7cf733ec9f3 (patch)
tree6d71bdafbff5c01d863747bd329471089eac1d42 /src/system
parent5f42ef3c92b3a1f5679e92ba3b2bb3a547c16da2 (diff)
downloadDLT-daemon-50771881e91bc78ad01720ad78eaa7cf733ec9f3.tar.gz
Bugfix: dlt-system-journal
* Don't pass a NULL pointer to localtime_r(...) and strftime(...) * Make sure that localtime_r(...) gets a pointer to time_t Signed-off-by: Sebastian Kloska <sebastian.kloska@daimler.com>
Diffstat (limited to 'src/system')
-rw-r--r--src/system/dlt-system-journal.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/system/dlt-system-journal.c b/src/system/dlt-system-journal.c
index ee3ddf0..6612988 100644
--- a/src/system/dlt-system-journal.c
+++ b/src/system/dlt-system-journal.c
@@ -136,9 +136,9 @@ int dlt_system_journal_get(sd_journal *j, char *target, const char *field, size_
void dlt_system_journal_get_timestamp(sd_journal *journal, MessageTimestamp *timestamp)
{
int ret = 0;
- uint64_t time_secs = 0;
+ time_t time_secs = 0;
uint64_t time_usecs = 0;
- struct tm *timeinfo = NULL;
+ struct tm timeinfo;
char buffer_realtime[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
char buffer_realtime_formatted[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
@@ -164,9 +164,9 @@ void dlt_system_journal_get_timestamp(sd_journal *journal, MessageTimestamp *tim
time_usecs = 0;
}
- time_secs = time_usecs / 1000000;
- localtime_r((const time_t *)(&time_secs), timeinfo);
- strftime(buffer_realtime_formatted, sizeof(buffer_realtime_formatted), "%Y/%m/%d %H:%M:%S", timeinfo);
+ time_secs = (time_t)(time_usecs / 1000000);
+ localtime_r(&time_secs, &timeinfo);
+ strftime(buffer_realtime_formatted, sizeof(buffer_realtime_formatted), "%Y/%m/%d %H:%M:%S", &timeinfo);
snprintf(timestamp->real, sizeof(timestamp->real), "%s.%06" PRIu64, buffer_realtime_formatted,
time_usecs % 1000000);