quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit bc9ba3e52e6ab56bb0761f95750c2c3be3012b52
parent eead7a5fd2cbe5aa54d278c8171bd9476f91b2e4
Author: Thomas Oltmann <thomas.oltmann.hhg@gmail.com>
Date:   Tue, 19 Apr 2022 12:20:40 +0200

Remove superfluous byteorder conversion

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.

Msock.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sock.c b/sock.c @@ -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)) == 0; 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;