[hackers] [quark][PATCH] Remove superfluous byteorder conversion

From: Thomas Oltmann <thomas.oltmann.hhg_AT_gmail.com>
Date: Tue, 19 Apr 2022 12:20:40 +0200

When comparing IPv4 addresses in sock_same_addr() we don't need
to correct their byteorder just to see if they are equal or not.
Byte swapping would only be needed if we needed to know
which address had the greater value.
---
 sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sock.c b/sock.c
index ecb73ef..f1385ca 100644
--- a/sock.c
+++ b/sock.c
_AT_@ -200,8 +200,8 @@ sock_same_addr(const struct sockaddr_storage *sa1, const struct sockaddr_storage
 		              ((struct sockaddr_in6 *)sa2)->sin6_addr.s6_addr,
 		              sizeof(((struct sockaddr_in6 *)sa1)->sin6_addr.s6_addr));
 	case AF_INET:
-		return ntohl(((struct sockaddr_in *)sa1)->sin_addr.s_addr) ==
-		       ntohl(((struct sockaddr_in *)sa2)->sin_addr.s_addr);
+		return ((struct sockaddr_in *)sa1)->sin_addr.s_addr ==
+		       ((struct sockaddr_in *)sa2)->sin_addr.s_addr;
 	default: /* AF_UNIX */
 		return strcmp(((struct sockaddr_un *)sa1)->sun_path,
 		              ((struct sockaddr_un *)sa2)->sun_path) == 0;
-- 
2.35.1
Received on Tue Apr 19 2022 - 12:20:40 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 19 2022 - 12:48:35 CEST