Skip to content

Commit 9e20b54

Browse files
committed
Fix timeval passing logic
The condition on the variable r does not work, since r is getting overriden after the sd_journal_get_realtime_usec() call.
1 parent 50887bf commit 9e20b54

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/netlog/netlog-manager.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int manager_read_journal_input(Manager *m) {
121121
structured_data_len = 0, msgid_len = 0, pid_len = 0;
122122
unsigned sev = JOURNAL_DEFAULT_SEVERITY;
123123
unsigned fac = JOURNAL_DEFAULT_FACILITY;
124-
struct timeval tv;
124+
struct timeval tv, *tvp = NULL;
125125
const void *data;
126126
usec_t realtime;
127127
size_t length;
@@ -169,8 +169,11 @@ static int manager_read_journal_input(Manager *m) {
169169
if (r < 0)
170170
log_warning_errno(r, "Failed to rerieve realtime from journal: %m");
171171
else {
172-
tv.tv_sec = realtime / USEC_PER_SEC;
173-
tv.tv_usec = realtime % USEC_PER_SEC;
172+
tv = (struct timeval) {
173+
.tv_sec = realtime / USEC_PER_SEC,
174+
.tv_usec = realtime % USEC_PER_SEC,
175+
};
176+
tvp = &tv;
174177
}
175178

176179
if (facility) {
@@ -197,7 +200,7 @@ static int manager_read_journal_input(Manager *m) {
197200
identifier,
198201
message, hostname,
199202
pid,
200-
r >= 0 ? &tv : NULL,
203+
tvp,
201204
structured_data,
202205
m->syslog_msgid ? msgid : NULL);
203206
}

0 commit comments

Comments
 (0)