Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Dec 2015 00:42:35 +0000 (UTC)
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r292850 - stable/10/lib/libc/net
Message-ID:  <201512290042.tBT0gZKd010204@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ume
Date: Tue Dec 29 00:42:35 2015
New Revision: 292850
URL: https://svnweb.freebsd.org/changeset/base/292850

Log:
  MFC r292550, r292595:
    Simplify _map_v4v6_address().
    We don't need to use a temporary buffer, here.

Modified:
  stable/10/lib/libc/net/map_v4v6.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/net/map_v4v6.c
==============================================================================
--- stable/10/lib/libc/net/map_v4v6.c	Tue Dec 29 00:08:32 2015	(r292849)
+++ stable/10/lib/libc/net/map_v4v6.c	Tue Dec 29 00:42:35 2015	(r292850)
@@ -77,19 +77,11 @@ typedef union {
 void
 _map_v4v6_address(const char *src, char *dst)
 {
-	u_char *p = (u_char *)dst;
-	char tmp[NS_INADDRSZ];
-	int i;
-
-	/* Stash a temporary copy so our caller can update in place. */
-	memcpy(tmp, src, NS_INADDRSZ);
+	/* Our caller may update in place. */
+	memmove(&dst[12], src, NS_INADDRSZ);
 	/* Mark this ipv6 addr as a mapped ipv4. */
-	for (i = 0; i < 10; i++)
-		*p++ = 0x00;
-	*p++ = 0xff;
-	*p++ = 0xff;
-	/* Retrieve the saved copy and we're done. */
-	memcpy((void*)p, tmp, NS_INADDRSZ);
+	memset(&dst[10], 0xff, 2);
+	memset(&dst[0], 0, 10);
 }
 
 void



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