diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-10-06 17:53:13 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-10-18 12:54:20 +0200 |
commit | af6321857dc9f0b9c1d58ec2fe4959aebc595c1b (patch) | |
tree | 5c2bb500f6efa2e5287c96e623b7750526a6b9a3 /src/shared/serialize.c | |
parent | serialize: add new helper deserialize_fd() (diff) | |
download | systemd-af6321857dc9f0b9c1d58ec2fe4959aebc595c1b.tar.xz systemd-af6321857dc9f0b9c1d58ec2fe4959aebc595c1b.zip |
serialize: modernize deserialize_{usec|dual_timestamp}() a bit
Rename the return parameters "ret", and use compound initialization. Add
an assert() on input.
Diffstat (limited to 'src/shared/serialize.c')
-rw-r--r-- | src/shared/serialize.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/shared/serialize.c b/src/shared/serialize.c index d62dfaa2d7..276e2b7b91 100644 --- a/src/shared/serialize.c +++ b/src/shared/serialize.c @@ -320,6 +320,7 @@ int deserialize_usec(const char *value, usec_t *ret) { int r; assert(value); + assert(ret); r = safe_atou64(value, ret); if (r < 0) @@ -328,12 +329,12 @@ int deserialize_usec(const char *value, usec_t *ret) { return 0; } -int deserialize_dual_timestamp(const char *value, dual_timestamp *t) { +int deserialize_dual_timestamp(const char *value, dual_timestamp *ret) { uint64_t a, b; int r, pos; assert(value); - assert(t); + assert(ret); pos = strspn(value, WHITESPACE); if (value[pos] == '-') @@ -353,8 +354,10 @@ int deserialize_dual_timestamp(const char *value, dual_timestamp *t) { /* trailing garbage */ return -EINVAL; - t->realtime = a; - t->monotonic = b; + *ret = (dual_timestamp) { + .realtime = a, + .monotonic = b, + }; return 0; } |