Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Aug 2023 00:35:56 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 3b6a41e84994 - stable/13 - libc vdso time functions: correctly convert errors into errnos
Message-ID:  <202308190035.37J0ZuLn050579@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3b6a41e84994350767335a3e008f1a02a628689f

commit 3b6a41e84994350767335a3e008f1a02a628689f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-08-12 15:45:43 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-08-19 00:35:29 +0000

    libc vdso time functions: correctly convert errors into errnos
    
    (cherry picked from commit 41acfee690da6289d570338e6365c1d7ef61dad5)
---
 lib/libc/sys/clock_gettime.c | 6 +++++-
 lib/libc/sys/gettimeofday.c  | 6 +++++-
 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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308190035.37J0ZuLn050579>