aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-08-12 15:45:43 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-08-12 22:34:08 +0000
commit41acfee690da6289d570338e6365c1d7ef61dad5 (patch)
tree965cc1180225264cedb9c5c532f30b212ea725e7 /lib/libc
parent220427da0e9b2c1d8e964120becc17eb7524e46f (diff)
downloadsrc-41acfee690da6289d570338e6365c1d7ef61dad5.tar.gz
src-41acfee690da6289d570338e6365c1d7ef61dad5.zip
libc vdso time functions: correctly convert errors into errnos
Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/sys/clock_gettime.c6
-rw-r--r--lib/libc/sys/gettimeofday.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/libc/sys/clock_gettime.c b/lib/libc/sys/clock_gettime.c
index ec8ec13a754d..b2a414455245 100644
--- a/lib/libc/sys/clock_gettime.c
+++ b/lib/libc/sys/clock_gettime.c
@@ -48,7 +48,11 @@ __clock_gettime(clockid_t clock_id, struct timespec *ts)
error = __vdso_clock_gettime(clock_id, ts);
else
error = ENOSYS;
- if (error == ENOSYS)
+ if (error == ENOSYS) {
error = __sys_clock_gettime(clock_id, ts);
+ } else if (error != 0) {
+ errno = error;
+ error = -1;
+ }
return (error);
}
diff --git a/lib/libc/sys/gettimeofday.c b/lib/libc/sys/gettimeofday.c
index 22177b15a5c7..d955aaa907e2 100644
--- a/lib/libc/sys/gettimeofday.c
+++ b/lib/libc/sys/gettimeofday.c
@@ -44,7 +44,11 @@ __gettimeofday(struct timeval *tv, struct timezone *tz)
int error;
error = __vdso_gettimeofday(tv, tz);
- if (error == ENOSYS)
+ if (error == ENOSYS) {
error = __sys_gettimeofday(tv, tz);
+ } else if (error != 0) {
+ errno = error;
+ error = -1;
+ }
return (error);
}