mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 19:21:53 +03:00
Merge pull request #2611 from 0xAX/deserialize-clkid
time-util: introduce deserialize_timestamp_value()
This commit is contained in:
commit
11ab173d40
@ -459,6 +459,19 @@ int dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deserialize_timestamp_value(const char *value, usec_t *timestamp) {
|
||||
int r;
|
||||
|
||||
assert(value);
|
||||
|
||||
r = safe_atou64(value, timestamp);
|
||||
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to parse finish timestamp value \"%s\": %m", value);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int parse_timestamp(const char *t, usec_t *usec) {
|
||||
static const struct {
|
||||
const char *name;
|
||||
|
@ -99,6 +99,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy);
|
||||
|
||||
void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
|
||||
int dual_timestamp_deserialize(const char *value, dual_timestamp *t);
|
||||
int deserialize_timestamp_value(const char *value, usec_t *timestamp);
|
||||
|
||||
int parse_timestamp(const char *t, usec_t *usec);
|
||||
|
||||
|
@ -446,17 +446,8 @@ int session_load(Session *s) {
|
||||
safe_close(fd);
|
||||
}
|
||||
|
||||
if (realtime) {
|
||||
unsigned long long l;
|
||||
if (sscanf(realtime, "%llu", &l) > 0)
|
||||
s->timestamp.realtime = l;
|
||||
}
|
||||
|
||||
if (monotonic) {
|
||||
unsigned long long l;
|
||||
if (sscanf(monotonic, "%llu", &l) > 0)
|
||||
s->timestamp.monotonic = l;
|
||||
}
|
||||
deserialize_timestamp_value(realtime, &s->timestamp.realtime);
|
||||
deserialize_timestamp_value(monotonic, &s->timestamp.monotonic);
|
||||
|
||||
if (controller) {
|
||||
if (bus_name_has_owner(s->manager->bus, controller, NULL) > 0)
|
||||
|
@ -321,17 +321,8 @@ int user_load(User *u) {
|
||||
if (s && s->display && display_is_local(s->display))
|
||||
u->display = s;
|
||||
|
||||
if (realtime) {
|
||||
unsigned long long l;
|
||||
if (sscanf(realtime, "%llu", &l) > 0)
|
||||
u->timestamp.realtime = l;
|
||||
}
|
||||
|
||||
if (monotonic) {
|
||||
unsigned long long l;
|
||||
if (sscanf(monotonic, "%llu", &l) > 0)
|
||||
u->timestamp.monotonic = l;
|
||||
}
|
||||
deserialize_timestamp_value(realtime, &u->timestamp.realtime);
|
||||
deserialize_timestamp_value(monotonic, &u->timestamp.monotonic);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -299,17 +299,8 @@ int machine_load(Machine *m) {
|
||||
m->class = c;
|
||||
}
|
||||
|
||||
if (realtime) {
|
||||
unsigned long long l;
|
||||
if (sscanf(realtime, "%llu", &l) > 0)
|
||||
m->timestamp.realtime = l;
|
||||
}
|
||||
|
||||
if (monotonic) {
|
||||
unsigned long long l;
|
||||
if (sscanf(monotonic, "%llu", &l) > 0)
|
||||
m->timestamp.monotonic = l;
|
||||
}
|
||||
deserialize_timestamp_value(realtime, &m->timestamp.realtime);
|
||||
deserialize_timestamp_value(monotonic, &m->timestamp.monotonic);
|
||||
|
||||
if (netif) {
|
||||
size_t allocated = 0, nr = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user