mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 02:20:12 +01:00
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:
parent
64326a42a9
commit
90b6491fa8
1 changed files with 7 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue