On Wed, 26 Jan 2022 18:25:19 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
>> Daniel Jeliński has updated the pull request with a new target base due to a >> merge or a rebase. The incremental webrev excludes the unrelated changes >> brought in by the merge/rebase. The pull request contains 12 additional >> commits since the last revision: >> >> - Fix invalid free >> - Merge remote-tracking branch 'origin' into interface-cleanup >> - Remove redundant initialization >> - Remove unused / incorrect exit code -2 from enumInterfaces >> - Address problems reported by clang-tidy >> - Restore support for IPv6-only operation >> - Fix memory leak >> - Fixup getAllInterfacesAndAddresses >> - Fixup getAddrsFromAdapter >> - Fixup enumAddresses_win >> - ... and 2 more: >> https://git.openjdk.java.net/jdk/compare/fec97562...98b40812 > > src/java.base/windows/native/libnet/NetworkInterface_winXP.c line 253: > >> 251: >> 252: ret = enumInterfaces(env, netifPP); >> 253: if (ret < 0) { > > Why did we remove handling for -2 here when `enumInterfaces` might return -2 > if it does not find any IPv4 network interface? Shouldn't we keep the code > that reset the exception status and set *netifPP = null here if ret == -2? `enumInterfaces` no longer returns -2. It does not fail on IPv6 machines, and if it failed, our code wouldn't recover anyway. After a discussion with @msheppar I decided to remove -2 from the list of possible return values. > src/java.base/windows/native/libnet/NetworkInterface_winXP.c line 271: > >> 269: ret = lookupIPAddrTable(env, &tableP); >> 270: if (ret == -1) { >> 271: free_netif(*netifPP); > > *netifPP might be null here. `free_netif` (and all other `free` functions) handle `null` input just fine. ------------- PR: https://git.openjdk.java.net/jdk/pull/6090