Skip to content

Commit

Permalink
lib, tests: Remove in6addr_cmp function from the system
Browse files Browse the repository at this point in the history
This function should just be memcmp.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Oct 30, 2024
1 parent d8f0b96 commit b44822b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
17 changes: 0 additions & 17 deletions lib/sockunion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion lib/sockunion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/test_frrlua.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b44822b

Please sign in to comment.