The branch main has been updated by des:

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

commit ff4b81eea88fbc3f2014d4f2f5e156de318376c1
Author:     Dag-Erling Smørgrav <[email protected]>
AuthorDate: 2026-09-05 15:44:18 +0000
Commit:     Dag-Erling Smørgrav <[email protected]>
CommitDate: 2026-09-05 15:44:35 +0000

    syscalls: Avoid C++ reserved words
    
    Both kern_renameat() and kern_dup() had arguments named `new`.  Rename
    their arguments to match their respecitve manual pages.
    
    Sponsored by:   Klara, Inc.
    Sponsored by:   NetApp, Inc.
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D59386
---
 sys/kern/kern_descrip.c | 46 +++++++++++++++++++++++-----------------------
 sys/kern/vfs_syscalls.c | 20 ++++++++++----------
 sys/sys/syscallsubr.h   |  6 +++---
 3 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 1d66581efb4c..bb806302fd03 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1040,7 +1040,7 @@ getmaxfd(struct thread *td)
  * Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD).
  */
 int
-kern_dup(struct thread *td, u_int mode, int flags, int old, int new)
+kern_dup(struct thread *td, u_int mode, int flags, int oldd, int newd)
 {
        struct filedesc *fdp;
        struct filedescent *oldfde, *newfde;
@@ -1056,34 +1056,34 @@ kern_dup(struct thread *td, u_int mode, int flags, int 
old, int new)
        MPASS((flags & ~(FDDUP_FLAG_CLOEXEC | FDDUP_FLAG_CLOFORK)) == 0);
        MPASS(mode < FDDUP_LASTMODE);
 
-       AUDIT_ARG_FD(old);
-       /* XXXRW: if (flags & FDDUP_FIXED) AUDIT_ARG_FD2(new); */
+       AUDIT_ARG_FD(oldd);
+       /* XXXRW: if (flags & FDDUP_FIXED) AUDIT_ARG_FD2(newd); */
 
        /*
         * Verify we have a valid descriptor to dup from and possibly to
         * dup to. Unlike dup() and dup2(), fcntl()'s F_DUPFD should
         * return EINVAL when the new descriptor is out of bounds.
         */
-       if (old < 0)
+       if (oldd < 0)
                return (EBADF);
-       if (new < 0)
+       if (newd < 0)
                return (mode == FDDUP_FCNTL ? EINVAL : EBADF);
        maxfd = getmaxfd(td);
-       if (new >= maxfd)
+       if (newd >= maxfd)
                return (mode == FDDUP_FCNTL ? EINVAL : EBADF);
 
        error = EBADF;
        FILEDESC_XLOCK(fdp);
-       if (fget_noref(fdp, old) == NULL)
+       if (fget_noref(fdp, oldd) == NULL)
                goto unlock;
-       if (mode == FDDUP_FIXED && old == new) {
-               td->td_retval[0] = new;
-               fdp->fd_ofiles[new].fde_flags |= fddup_to_fde_flags(flags);
+       if (mode == FDDUP_FIXED && oldd == newd) {
+               td->td_retval[0] = newd;
+               fdp->fd_ofiles[newd].fde_flags |= fddup_to_fde_flags(flags);
                error = 0;
                goto unlock;
        }
 
-       oldfde = &fdp->fd_ofiles[old];
+       oldfde = &fdp->fd_ofiles[oldd];
        oldfp = oldfde->fde_file;
        if (!fhold(oldfp))
                goto unlock;
@@ -1096,13 +1096,13 @@ kern_dup(struct thread *td, u_int mode, int flags, int 
old, int new)
        switch (mode) {
        case FDDUP_NORMAL:
        case FDDUP_FCNTL:
-               if ((error = fdalloc(td, new, &new)) != 0) {
+               if ((error = fdalloc(td, newd, &newd)) != 0) {
                        fdrop(oldfp, td);
                        goto unlock;
                }
                break;
        case FDDUP_FIXED:
-               if (new >= fdp->fd_nfiles) {
+               if (newd >= fdp->fd_nfiles) {
                        /*
                         * The resource limits are here instead of e.g.
                         * fdalloc(), because the file descriptor table may be
@@ -1113,7 +1113,7 @@ kern_dup(struct thread *td, u_int mode, int flags, int 
old, int new)
                         */
 #ifdef RACCT
                        if (RACCT_ENABLED()) {
-                               error = racct_set_unlocked(p, RACCT_NOFILE, new 
+ 1);
+                               error = racct_set_unlocked(p, RACCT_NOFILE, 
newd + 1);
                                if (error != 0) {
                                        error = EMFILE;
                                        fdrop(oldfp, td);
@@ -1121,24 +1121,24 @@ kern_dup(struct thread *td, u_int mode, int flags, int 
old, int new)
                                }
                        }
 #endif
-                       fdgrowtable_exp(fdp, new + 1);
+                       fdgrowtable_exp(fdp, newd + 1);
                }
-               if (!fdisused(fdp, new))
-                       fdused(fdp, new);
+               if (!fdisused(fdp, newd))
+                       fdused(fdp, newd);
                break;
        default:
                KASSERT(0, ("%s unsupported mode %d", __func__, mode));
        }
 
-       KASSERT(old != new, ("new fd is same as old"));
+       KASSERT(oldd != newd, ("new fd is same as old"));
 
        /* Refetch oldfde because the table may have grown and old one freed. */
-       oldfde = &fdp->fd_ofiles[old];
+       oldfde = &fdp->fd_ofiles[oldd];
        KASSERT(oldfp == oldfde->fde_file,
            ("fdt_ofiles shift from growth observed at fd %d",
-           old));
+           oldd));
 
-       newfde = &fdp->fd_ofiles[new];
+       newfde = &fdp->fd_ofiles[newd];
        delfp = newfde->fde_file;
 
        nioctls = filecaps_copy_prep(&oldfde->fde_caps);
@@ -1158,12 +1158,12 @@ kern_dup(struct thread *td, u_int mode, int flags, int 
old, int new)
 #ifdef CAPABILITIES
        seqc_write_end(&newfde->fde_seqc);
 #endif
-       td->td_retval[0] = new;
+       td->td_retval[0] = newd;
 
        error = 0;
 
        if (delfp != NULL) {
-               (void) closefp(fdp, new, delfp, td, true, false);
+               (void) closefp(fdp, newd, delfp, td, true, false);
                FILEDESC_UNLOCK_ASSERT(fdp);
        } else {
 unlock:
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index e82ac8fe9ead..9bae2cd6b854 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -3751,14 +3751,14 @@ sys_renameat2(struct thread *td, struct renameat2_args 
*uap)
 
 #ifdef MAC
 static int
-kern_renameat_mac(struct thread *td, int oldfd, const char *old, int newfd,
-    const char *new, enum uio_seg pathseg, struct nameidata *fromnd, int op,
+kern_renameat_mac(struct thread *td, int fromfd, const char *from, int tofd,
+    const char *to, enum uio_seg pathseg, struct nameidata *fromnd, int op,
     int ndflags)
 {
        int error;
 
        NDINIT_ATRIGHTS(fromnd, op, LOCKPARENT | LOCKLEAF | AUDITVNODE1 |
-           ndflags, pathseg, old, oldfd, &cap_renameat_source_rights);
+           ndflags, pathseg, from, fromfd, &cap_renameat_source_rights);
        if ((error = namei(fromnd)) != 0)
                return (error);
        error = mac_vnode_check_rename_from(td->td_ucred, fromnd->ni_dvp,
@@ -3776,8 +3776,8 @@ kern_renameat_mac(struct thread *td, int oldfd, const 
char *old, int newfd,
 #endif
 
 int
-kern_renameat(struct thread *td, int oldfd, const char *old, int newfd,
-    const char *new, enum uio_seg pathseg, u_int flags)
+kern_renameat(struct thread *td, int fromfd, const char *from, int tofd,
+    const char *to, enum uio_seg pathseg, u_int flags)
 {
        struct mount *mp, *tmp;
        struct vnode *tvp, *fvp, *tdvp;
@@ -3805,14 +3805,14 @@ again:
        bwillwrite();
 #ifdef MAC
        if (mac_vnode_check_rename_from_enabled()) {
-               error = kern_renameat_mac(td, oldfd, old, newfd, new, pathseg,
+               error = kern_renameat_mac(td, fromfd, from, tofd, to, pathseg,
                    &fromnd, op, fndflags);
                if (error != 0)
                        return (error);
        } else {
 #endif
        NDINIT_ATRIGHTS(&fromnd, op, WANTPARENT | AUDITVNODE1 | fndflags,
-           pathseg, old, oldfd, &cap_renameat_source_rights);
+           pathseg, from, fromfd, &cap_renameat_source_rights);
        if ((error = namei(&fromnd)) != 0)
                return (error);
 #ifdef MAC
@@ -3834,7 +3834,7 @@ again:
        tondflags = LOCKPARENT | LOCKLEAF | NOCACHE | AUDITVNODE2;
        if (fromnd.ni_vp->v_type == VDIR)
                tondflags |= WILLBEDIR;
-       NDINIT_ATRIGHTS(&tond, RENAME, tondflags, pathseg, new, newfd,
+       NDINIT_ATRIGHTS(&tond, RENAME, tondflags, pathseg, to, tofd,
            &cap_renameat_target_rights);
        if ((error = namei(&tond)) != 0) {
                /* Translate error code for rename("dir1", "dir2/."). */
@@ -3945,10 +3945,10 @@ again1:
                        }
                }
 #ifdef CAPABILITIES
-               if (newfd != AT_FDCWD && (tond.ni_resflags & NIRES_ABS) == 0) {
+               if (tofd != AT_FDCWD && (tond.ni_resflags & NIRES_ABS) == 0) {
                        /*
                         * If the target already exists we require CAP_UNLINKAT
-                        * from 'newfd', when newfd was used for the lookup.
+                        * from 'tofd', when tofd was used for the lookup.
                         */
                        error = cap_check(&tond.ni_filecaps.fc_rights,
                            &cap_unlinkat_rights);
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index e7a118195b53..190dd41ce6ee 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -133,7 +133,7 @@ int kern_cpuset_getid(struct thread *td, cpulevel_t level,
            cpuwhich_t which, id_t id, cpusetid_t *setid);
 int    kern_cpuset_setid(struct thread *td, cpuwhich_t which,
            id_t id, cpusetid_t setid);
-int    kern_dup(struct thread *td, u_int mode, int flags, int old, int new);
+int    kern_dup(struct thread *td, u_int mode, int flags, int oldd, int newd);
 int    kern_execve(struct thread *td, struct image_args *args,
            struct mac *mac_p, struct vmspace *oldvmspace);
 void   kern_exit(struct thread *, int, int);
@@ -318,8 +318,8 @@ int kern_readlinkat(struct thread *td, int fd, const char 
*path,
 int    kern_readv(struct thread *td, int fd, struct uio *auio);
 int    kern_recvit(struct thread *td, int s, struct msghdr *mp,
            enum uio_seg fromseg, struct mbuf **controlp);
-int    kern_renameat(struct thread *td, int oldfd, const char *old, int newfd,
-           const char *new, enum uio_seg pathseg, u_int flags);
+int    kern_renameat(struct thread *td, int fromfd, const char *from,
+           int tofd, const char *to, enum uio_seg pathseg, u_int flags);
 int    kern_sched_getparam(struct thread *td, struct thread *targettd,
            struct sched_param *param);
 int    kern_sched_getscheduler(struct thread *td, struct thread *targettd,

Reply via email to