From b44822b42f4bdc4e98e819813e2068e2fe30afca Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 30 Oct 2024 10:41:08 -0400 Subject: [PATCH] lib, tests: Remove in6addr_cmp function from the system This function should just be memcmp. Signed-off-by: Donald Sharp --- lib/sockunion.c | 17 ----------------- lib/sockunion.h | 1 - tests/lib/test_frrlua.c | 2 +- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/lib/sockunion.c b/lib/sockunion.c index b8ecef268724..e6f7661d7360 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -588,23 +588,6 @@ static void __attribute__((unused)) sockunion_print(const union sockunion *su) } } -int in6addr_cmp(const struct in6_addr *addr1, const struct in6_addr *addr2) -{ - unsigned int i; - const uint8_t *p1, *p2; - - p1 = (const uint8_t *)addr1; - p2 = (const uint8_t *)addr2; - - for (i = 0; i < sizeof(struct in6_addr); i++) { - if (p1[i] > p2[i]) - return 1; - else if (p1[i] < p2[i]) - return -1; - } - return 0; -} - int sockunion_cmp(const union sockunion *su1, const union sockunion *su2) { if (su1->sa.sa_family > su2->sa.sa_family) diff --git a/lib/sockunion.h b/lib/sockunion.h index 146651225cdf..5152e70a234b 100644 --- a/lib/sockunion.h +++ b/lib/sockunion.h @@ -93,7 +93,6 @@ enum connect_result { connect_error, connect_success, connect_in_progress }; /* Prototypes. */ extern int str2sockunion(const char *, union sockunion *); extern const char *sockunion2str(const union sockunion *, char *, size_t); -int in6addr_cmp(const struct in6_addr *addr1, const struct in6_addr *addr2); extern int sockunion_cmp(const union sockunion *, const union sockunion *); extern int sockunion_same(const union sockunion *, const union sockunion *); extern unsigned int sockunion_hash(const union sockunion *); diff --git a/tests/lib/test_frrlua.c b/tests/lib/test_frrlua.c index 4aa8c8a8c396..9a1c3eaab66a 100644 --- a/tests/lib/test_frrlua.c +++ b/tests/lib/test_frrlua.c @@ -90,7 +90,7 @@ static void test_encode_decode(void) lua_pushin6addr(L, &in6addr_a); lua_decode_in6addr(L, -1, &in6addr_a); - assert(in6addr_cmp(&in6addr_a, &in6addr_b) == 0); + assert(memcmp(&in6addr_a, &in6addr_b, sizeof(struct in6_addr)) == 0); assert(lua_gettop(L) == 0); union sockunion su_a, su_b;