glib-aux: don't assert for integer range in nm_utils_monotonic_timestamp_from_boottime()

The boottime argument might come from the system, and we should not
assert that it's reasonably small. It might be infinity. In that
case, keep it at infinity.
This commit is contained in:
Thomas Haller 2022-10-13 11:03:41 +02:00
parent 64326a42a9
commit 90b6491fa8
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -301,8 +301,13 @@ nm_utils_monotonic_timestamp_from_boottime(guint64 boottime, gint64 timestamp_ns
nm_assert(offset <= 0 && offset > G_MININT64);
/* check for overflow (note that offset is non-positive). */
g_return_val_if_fail(boottime < G_MAXINT64, G_MAXINT64);
if (boottime >= (guint64) G_MAXINT64) {
/* This indicates infinity. We keep it at such. */
return G_MAXINT64;
}
/* Note that overflow cannot happen, because bootime is non-negative, and
* offset is non-positive. */
return (gint64) boottime + offset;
}