Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2022 19:39:13 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: cadaecc91e97 - stable/13 - linux(4): Microoptimize bsd_to_linux_sockaddr().
Message-ID:  <202206171939.25HJdDsX015732@gitrepo.freebsd.org>

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

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

commit cadaecc91e971795c57b26591b141d7749191309
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-04-25 07:21:20 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:33:54 +0000

    linux(4): Microoptimize bsd_to_linux_sockaddr().
    
    Differential Revision:  https://reviews.freebsd.org/D34725
    MFC after:              2 weeks
    
    (cherry picked from commit bbddd5881d1826a366d09d1e156ec6b64d3715e5)
---
 sys/compat/linux/linux.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c
index 8cc678e1ec7d..414edc2446bd 100644
--- a/sys/compat/linux/linux.c
+++ b/sys/compat/linux/linux.c
@@ -400,28 +400,20 @@ bsd_to_linux_sockaddr(const struct sockaddr *sa, struct l_sockaddr **lsa,
     socklen_t len)
 {
 	struct l_sockaddr *kosa;
-	int error, bdom;
+	int bdom;
 
 	*lsa = NULL;
 	if (len < 2 || len > UCHAR_MAX)
 		return (EINVAL);
+	bdom = bsd_to_linux_domain(sa->sa_family);
+	if (bdom == -1)
+		return (EAFNOSUPPORT);
 
 	kosa = malloc(len, M_SONAME, M_WAITOK);
 	bcopy(sa, kosa, len);
-
-	bdom = bsd_to_linux_domain(sa->sa_family);
-	if (bdom == -1) {
-		error = EAFNOSUPPORT;
-		goto out;
-	}
-
 	kosa->sa_family = bdom;
 	*lsa = kosa;
 	return (0);
-
-out:
-	free(kosa, M_SONAME);
-	return (error);
 }
 
 int



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