The branch main has been updated by brooks:

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

commit ec2b6b16aac4d2873a856658d4cd6001ec255dc7
Author:     Brooks Davis <bro...@freebsd.org>
AuthorDate: 2024-05-08 14:49:13 +0000
Commit:     Brooks Davis <bro...@freebsd.org>
CommitDate: 2024-05-08 14:49:13 +0000

    libthr: avoid varargs in fcntl and openat interposers
    
    Align these signatures with the ones in syscalls.master (and thus
    libsys.h).  There's no reason to do va_args twice and in some ABIs
    (e.g,, CheriABI) you can't access fixed arguments as varargs if you
    weren't called with varargs signature.
    
    Reviewed by:    imp, kib, jhibbits
    Obtained from:  CheriBSD
    Differential Revision:  https://reviews.freebsd.org/D45126
---
 lib/libthr/thread/thr_private.h  |  4 ++--
 lib/libthr/thread/thr_syscalls.c | 25 +++++--------------------
 2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index f89941f96c78..de65e8e7353d 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -864,8 +864,8 @@ int _pthread_mutexattr_setrobust(pthread_mutexattr_t * 
_Nonnull, int);
 /* #include <fcntl.h> */
 #ifdef  _SYS_FCNTL_H_
 #ifndef _LIBC_PRIVATE_H_
-int     __sys_fcntl(int, int, ...);
-int     __sys_openat(int, const char *, int, ...);
+int     __sys_fcntl(int, int, intptr_t);
+int     __sys_openat(int, const char *, int, int);
 #endif /* _LIBC_PRIVATE_H_ */
 #endif /* _SYS_FCNTL_H_ */
 
diff --git a/lib/libthr/thread/thr_syscalls.c b/lib/libthr/thread/thr_syscalls.c
index ba07c92576c2..22f9c1f68ec2 100644
--- a/lib/libthr/thread/thr_syscalls.c
+++ b/lib/libthr/thread/thr_syscalls.c
@@ -188,22 +188,19 @@ __thr_connect(int fd, const struct sockaddr *name, 
socklen_t namelen)
  *   if it is canceled.
  */
 static int
-__thr_fcntl(int fd, int cmd, ...)
+__thr_fcntl(int fd, int cmd, __intptr_t arg)
 {
        struct pthread *curthread;
        int ret;
-       va_list ap;
 
        curthread = _get_curthread();
-       va_start(ap, cmd);
        if (cmd == F_OSETLKW || cmd == F_SETLKW) {
                _thr_cancel_enter(curthread);
-               ret = __sys_fcntl(fd, cmd, (intptr_t)va_arg(ap, void *));
+               ret = __sys_fcntl(fd, cmd, arg);
                _thr_cancel_leave(curthread, ret == -1);
        } else {
-               ret = __sys_fcntl(fd, cmd, (intptr_t)va_arg(ap, void *));
+               ret = __sys_fcntl(fd, cmd, arg);
        }
-       va_end(ap);
 
        return (ret);
 }
@@ -294,23 +291,11 @@ __thr_nanosleep(const struct timespec *time_to_sleep,
  *   If the thread is canceled, file is not opened.
  */
 static int
-__thr_openat(int fd, const char *path, int flags, ...)
+__thr_openat(int fd, const char *path, int flags, int mode)
 {
        struct pthread *curthread;
-       int mode, ret;
-       va_list ap;
+       int ret;
 
-       
-       /* Check if the file is being created: */
-       if ((flags & O_CREAT) != 0) {
-               /* Get the creation mode: */
-               va_start(ap, flags);
-               mode = va_arg(ap, int);
-               va_end(ap);
-       } else {
-               mode = 0;
-       }
-       
        curthread = _get_curthread();
        _thr_cancel_enter(curthread);
        ret = __sys_openat(fd, path, flags, mode);

Reply via email to