diff options
author | Thomas Haller <thaller@redhat.com> | 2019-07-25 15:07:05 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-07-25 15:10:43 +0200 |
commit | 9dfc3ff5af44324abe92001d2588dced3372da1b (patch) | |
tree | b9909ed8eefde67852de64d60fa4d4f0efeb07ca /shared | |
parent | 12d9ef4c3698d22e0218cb08b756ec3f9ca8f05e (diff) | |
download | NetworkManager-9dfc3ff5af44324abe92001d2588dced3372da1b.tar.gz |
core: improve code comment and add assertion to nm_utils_monotonic_timestamp_as_boottime()
Diffstat (limited to 'shared')
-rw-r--r-- | shared/nm-glib-aux/nm-time-utils.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/shared/nm-glib-aux/nm-time-utils.c b/shared/nm-glib-aux/nm-time-utils.c index 4f4c51a964..7735f29d49 100644 --- a/shared/nm-glib-aux/nm-time-utils.c +++ b/shared/nm-glib-aux/nm-time-utils.c @@ -231,15 +231,15 @@ nm_utils_get_monotonic_timestamp_s (void) /** * nm_utils_monotonic_timestamp_as_boottime: * @timestamp: the monotonic-timestamp that should be converted into CLOCK_BOOTTIME. - * @timestamp_ns_per_tick: How many nano seconds make one unit of @timestamp? E.g. if - * @timestamp is in unit seconds, pass %NM_UTILS_NS_PER_SECOND; @timestamp in nano - * seconds, pass 1; @timestamp in milliseconds, pass %NM_UTILS_NS_PER_SECOND/1000; etc. + * @timestamp_ns_per_tick: How many nanoseconds make one unit of @timestamp? E.g. if + * @timestamp is in unit seconds, pass %NM_UTILS_NS_PER_SECOND; if @timestamp is + * in nanoseconds, pass 1; if @timestamp is in milliseconds, pass %NM_UTILS_NS_PER_SECOND/1000. * * Returns: the monotonic-timestamp as CLOCK_BOOTTIME, as returned by clock_gettime(). - * The unit is the same as the passed in @timestamp basd on @timestamp_ns_per_tick. - * E.g. if you passed @timestamp in as seconds, it will return boottime in seconds. - * If @timestamp is a non-positive, it returns -1. Note that a (valid) monotonic-timestamp - * is always positive. + * The unit is the same as the passed in @timestamp based on @timestamp_ns_per_tick. + * E.g. if you passed @timestamp in as seconds, it will return boottime in seconds. + * If @timestamp is non-positive, it returns -1. Note that a (valid) monotonic-timestamp + * is always positive. * * On older kernels that don't support CLOCK_BOOTTIME, the returned time is instead CLOCK_MONOTONIC. **/ @@ -265,6 +265,8 @@ nm_utils_monotonic_timestamp_as_boottime (gint64 timestamp, gint64 timestamp_ns_ p = _t_get_global_state (); + nm_assert (p->offset_sec <= 0); + /* calculate the offset of monotonic-timestamp to boottime. offset_s is <= 1. */ offset = p->offset_sec * (NM_UTILS_NS_PER_SECOND / timestamp_ns_per_tick); |