[2/2] iphlpapi: Use the new version of the IP_ADAPTER_UNICAST_ADDRESS structure (try 2)

Henri Verbeet hverbeet at gmail.com
Fri Jan 13 08:34:54 CST 2017


On 13 January 2017 at 14:43, Hans Leidekker <hans at codeweavers.com> wrote:
> On Fri, 2017-01-13 at 13:27 +0100, André Hentschel wrote:
>> diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
>> index 54f7a37..223d980 100644
>> --- a/dlls/iphlpapi/iphlpapi_main.c
>> +++ b/dlls/iphlpapi/iphlpapi_main.c
>> @@ -1065,6 +1065,13 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
>>                        debugstr_ipv4(&sa->sin_addr.S_un.S_addr, addr_buf));
>>                  fill_unicast_addr_data(aa, ua);
>>
>> +                ua->OnLinkPrefixLength = 0;
>> +                for (j = 0; j < sizeof(*v4masks) * 8; j++)
>> +                {
>> +                    if (v4masks[i] & 1 << j) ua->OnLinkPrefixLength++;
>> +                    else break;
>> +                }
>> +
>
> Please add a helper to compute prefix length instead of duplicating this code.
> This should probably wait until the code freeze is over.
>
For what it's worth, if you're adding a helper function anyway, note
that you're really just counting the number of trailing zero-bits. GCC
has __builtin_ctz() for that, but even without that there are better
approaches than testing each bit individually. Alternatively, there's
also __builtin_popcount().



More information about the wine-devel mailing list