git: a836accf4cca - stable/13 - linux(4): Microoptimize futimesat, utimes, utime. While here wrap long line.

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Fri, 17 Jun 2022 19:24:10 UTC
The branch stable/13 has been updated by dchagin:

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

commit a836accf4cca5f905238785355175d4fe620ae79
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-05-31 19:54:18 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:22:17 +0000

    linux(4): Microoptimize futimesat, utimes, utime.
    While here wrap long line.
    
    Differential Revision:  https://reviews.freebsd.org/D30488
    MFC after:              2 weeks
    
    (cherry picked from commit 2a0fa277f66b0dc81a97d0f7fc6dc91ff5a7fd9c)
---
 sys/compat/linux/linux_misc.c | 40 +++++++++++-----------------------------
 1 file changed, 11 insertions(+), 29 deletions(-)

diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 023d98f2ec34..17a45b5e5b7a 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -722,18 +722,10 @@ linux_utime(struct thread *td, struct linux_utime_args *args)
 	struct l_utimbuf lut;
 	char *fname;
 	int error;
-	bool convpath;
-
-	convpath = LUSECONVPATH(td);
-	if (convpath)
-		LCONVPATHEXIST(td, args->fname, &fname);
 
 	if (args->times) {
-		if ((error = copyin(args->times, &lut, sizeof lut))) {
-			if (convpath)
-				LFREEPATH(fname);
+		if ((error = copyin(args->times, &lut, sizeof lut)) != 0)
 			return (error);
-		}
 		tv[0].tv_sec = lut.l_actime;
 		tv[0].tv_usec = 0;
 		tv[1].tv_sec = lut.l_modtime;
@@ -742,10 +734,11 @@ linux_utime(struct thread *td, struct linux_utime_args *args)
 	} else
 		tvp = NULL;
 
-	if (!convpath) {
+	if (!LUSECONVPATH(td)) {
 		error = kern_utimesat(td, AT_FDCWD, args->fname, UIO_USERSPACE,
 		    tvp, UIO_SYSSPACE);
 	} else {
+		LCONVPATHEXIST(td, args->fname, &fname);
 		error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE, tvp,
 		    UIO_SYSSPACE);
 		LFREEPATH(fname);
@@ -762,17 +755,10 @@ linux_utimes(struct thread *td, struct linux_utimes_args *args)
 	struct timeval tv[2], *tvp = NULL;
 	char *fname;
 	int error;
-	bool convpath;
-
-	convpath = LUSECONVPATH(td);
-	if (convpath)
-		LCONVPATHEXIST(td, args->fname, &fname);
 
 	if (args->tptr != NULL) {
-		if ((error = copyin(args->tptr, ltv, sizeof ltv))) {
-			LFREEPATH(fname);
+		if ((error = copyin(args->tptr, ltv, sizeof ltv)) != 0)
 			return (error);
-		}
 		tv[0].tv_sec = ltv[0].tv_sec;
 		tv[0].tv_usec = ltv[0].tv_usec;
 		tv[1].tv_sec = ltv[1].tv_sec;
@@ -780,10 +766,11 @@ linux_utimes(struct thread *td, struct linux_utimes_args *args)
 		tvp = tv;
 	}
 
-	if (!convpath) {
+	if (!LUSECONVPATH(td)) {
 		error = kern_utimesat(td, AT_FDCWD, args->fname, UIO_USERSPACE,
 		    tvp, UIO_SYSSPACE);
 	} else {
+		LCONVPATHEXIST(td, args->fname, &fname);
 		error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE,
 		    tvp, UIO_SYSSPACE);
 		LFREEPATH(fname);
@@ -897,19 +884,12 @@ linux_futimesat(struct thread *td, struct linux_futimesat_args *args)
 	struct timeval tv[2], *tvp = NULL;
 	char *fname;
 	int error, dfd;
-	bool convpath;
 
-	convpath = LUSECONVPATH(td);
 	dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
-	if (convpath)
-		LCONVPATHEXIST_AT(td, args->filename, &fname, dfd);
 
 	if (args->utimes != NULL) {
-		if ((error = copyin(args->utimes, ltv, sizeof ltv))) {
-			if (convpath)
-				LFREEPATH(fname);
+		if ((error = copyin(args->utimes, ltv, sizeof ltv)) != 0)
 			return (error);
-		}
 		tv[0].tv_sec = ltv[0].tv_sec;
 		tv[0].tv_usec = ltv[0].tv_usec;
 		tv[1].tv_sec = ltv[1].tv_sec;
@@ -917,11 +897,13 @@ linux_futimesat(struct thread *td, struct linux_futimesat_args *args)
 		tvp = tv;
 	}
 
-	if (!convpath) {
+	if (!LUSECONVPATH(td)) {
 		error = kern_utimesat(td, dfd, args->filename, UIO_USERSPACE,
 		    tvp, UIO_SYSSPACE);
 	} else {
-		error = kern_utimesat(td, dfd, fname, UIO_SYSSPACE, tvp, UIO_SYSSPACE);
+		LCONVPATHEXIST_AT(td, args->filename, &fname, dfd);
+		error = kern_utimesat(td, dfd, fname, UIO_SYSSPACE,
+		    tvp, UIO_SYSSPACE);
 		LFREEPATH(fname);
 	}
 	return (error);