Mark,

1. If I read the code correctly,

ll. 168 - 177 is exactly the same as ll. 180 - 189

Could you refactor the fix to avoid code duplication?

Would something like

if (
   (ptr->IfIndex != 0 && ptr->IfIndex == index) ||
   (ptr->Ipv6IfIndex != 0 && ptr->Ipv6IfIndex == index)
) {
...
}

work?


2. It seems to me passed index couldn't be 0 so null check is redundant,
but I don't mind to keep it.
  It might make sense to explicitly check passed index for 0 above loop.

-Dmitry



On 2013-09-03 13:23, Mark Sheppard wrote:
> Hi
> please oblige and review the fix below to address the issue in JDK-8021372:
> NetworkInterface.getNetworkInterfaces() returns duplicate hardware address
> 
> http://cr.openjdk.java.net/~msheppar/8021372/webrev/
> 
> the handling of the Ipv6IfIndex was suspect when setting the
> interface index and when retrieving the mac address using the index.
> 
> in the getAdpaters function, the conditaionalstatement could be rolled
> into one.
> But, as there was a spurious IPv4 comment, I structured it as an if
> else. statement.
> 
> It should be noted that IfIndex and the Ipv6IfIndex can be zero, which
> implies that the
> IPv4 or IPv6 interface is not available. This may be at odds with the
> setting of a default index to 0 in the Java NetworkInterface abstraction,
> where a defaultIndex of zero is used.
> 
> JPRTs have been run and show no side effects.
> 
> regards
> Mark


-- 
Dmitry Samersoff
Oracle Java development team, Saint Petersburg, Russia
* I would love to change the world, but they won't give me the sources.

Reply via email to