aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-06-06 20:09:49 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-06-07 20:44:44 +0200
commit3f63743a65bf3d987615774cdab0a9cb1006ae47 (patch)
tree73f480fecfb74885b272eb9a6c0806ae0566e044 /util.c
parentf9e8ee0777c257ffd2956a6dd51e866dff26bc8e (diff)
downloadpasst-3f63743a65bf3d987615774cdab0a9cb1006ae47.tar
passt-3f63743a65bf3d987615774cdab0a9cb1006ae47.tar.gz
passt-3f63743a65bf3d987615774cdab0a9cb1006ae47.tar.bz2
passt-3f63743a65bf3d987615774cdab0a9cb1006ae47.tar.lz
passt-3f63743a65bf3d987615774cdab0a9cb1006ae47.tar.xz
passt-3f63743a65bf3d987615774cdab0a9cb1006ae47.tar.zst
passt-3f63743a65bf3d987615774cdab0a9cb1006ae47.zip
util: Use 'long' to represent millisecond durations
timespec_diff_ms() returns an int representing a duration in milliseconds. This will overflow in about 25 days when an int is 32 bits. The way we use this function, we're probably not going to get a result that long, but it's not outrageously implausible. Use a long for safety. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.c')
-rw-r--r--util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util.c b/util.c
index 5e854a2..4446180 100644
--- a/util.c
+++ b/util.c
@@ -216,7 +216,7 @@ void sock_probe_mem(struct ctx *c)
*
* Return: difference in milliseconds
*/
-int timespec_diff_ms(const struct timespec *a, const struct timespec *b)
+long timespec_diff_ms(const struct timespec *a, const struct timespec *b)
{
if (a->tv_nsec < b->tv_nsec) {
return (b->tv_nsec - a->tv_nsec) / 1000000 +