Skip to content

Commit

Permalink
uls_inet6: We always need to start clearing from the last word back,
Browse files Browse the repository at this point in the history
this does not vary based on the number of bits.
  • Loading branch information
jkroonza committed Jul 17, 2024
1 parent d602e4c commit a795f2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/uls_inet6.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static
void in6_clear_host_bits(struct in6_addr *in6, int prefix_len)
{
int bits_to_clear = 128 - prefix_len;
int clear_index = prefix_len >> 5; /* we deal with 32 bits at a time */
int clear_index = 128 / 32 - 1;

while (bits_to_clear >= 32) {
in6->s6_addr32[clear_index--] = 0;
Expand All @@ -22,7 +22,7 @@ static
void in6_set_host_bits(struct in6_addr *in6, int prefix_len)
{
int bits_to_set = 128 - prefix_len;
int set_index = prefix_len >> 5; /* we deal with 32 bits at a time */
int set_index = 128 / 32 - 1;

while (bits_to_set >= 32) {
in6->s6_addr32[set_index--] = ~0U;
Expand Down

0 comments on commit a795f2e

Please sign in to comment.