Author: kib
Date: Fri Dec  7 23:07:51 2018
New Revision: 341712
URL: https://svnweb.freebsd.org/changeset/base/341712

Log:
  Simplify kern_readlink_vp().
  
  When we detected that the vnode is not symlink, return immediately.
  This moves the readlink code out of else branch and unindents it.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/kern/vfs_syscalls.c

Modified: head/sys/kern/vfs_syscalls.c
==============================================================================
--- head/sys/kern/vfs_syscalls.c        Fri Dec  7 23:05:12 2018        
(r341711)
+++ head/sys/kern/vfs_syscalls.c        Fri Dec  7 23:07:51 2018        
(r341712)
@@ -2539,20 +2539,19 @@ kern_readlink_vp(struct vnode *vp, char *buf, enum uio
                return (error);
 #endif
        if (vp->v_type != VLNK && (vp->v_vflag & VV_READLINK) == 0)
-               error = EINVAL;
-       else {
-               aiov.iov_base = buf;
-               aiov.iov_len = count;
-               auio.uio_iov = &aiov;
-               auio.uio_iovcnt = 1;
-               auio.uio_offset = 0;
-               auio.uio_rw = UIO_READ;
-               auio.uio_segflg = bufseg;
-               auio.uio_td = td;
-               auio.uio_resid = count;
-               error = VOP_READLINK(vp, &auio, td->td_ucred);
-               td->td_retval[0] = count - auio.uio_resid;
-       }
+               return (EINVAL);
+
+       aiov.iov_base = buf;
+       aiov.iov_len = count;
+       auio.uio_iov = &aiov;
+       auio.uio_iovcnt = 1;
+       auio.uio_offset = 0;
+       auio.uio_rw = UIO_READ;
+       auio.uio_segflg = bufseg;
+       auio.uio_td = td;
+       auio.uio_resid = count;
+       error = VOP_READLINK(vp, &auio, td->td_ucred);
+       td->td_retval[0] = count - auio.uio_resid;
        return (error);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to