From bbb377fd423a9e2c65e0dd92bc599505bad68cb7 Mon Sep 17 00:00:00 2001 From: Alan Jian Date: Mon, 26 Feb 2024 11:47:49 +0800 Subject: [PATCH] Fix the microsecond-to-nanosecond conversion in rv_clock_gettime() A microsecond is 1000 times bigger than a nanosecond (1e-6 vs 1e-9 seconds). This commit corrects the conversion of microseconds to nanoseconds in rv_clock_gettime() by multiplying tv_usec by 1000 instead of dividing it. --- src/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index a6acd809..65285902 100644 --- a/src/utils.c +++ b/src/utils.c @@ -69,7 +69,7 @@ void rv_clock_gettime(struct timespec *tp) int32_t tv_sec, tv_usec; get_time_info(&tv_sec, &tv_usec); tp->tv_sec = tv_sec; - tp->tv_nsec = tv_usec / 1000; /* Transfer to microseconds */ + tp->tv_nsec = tv_usec * 1000; /* Transfer to microseconds */ } char *sanitize_path(const char *input)