RFR(S): 8156521: Minor Fixes and cleanups in NetworkInterface.c

Mark Sheppard mark.sheppard at oracle.com
Wed May 11 11:12:28 UTC 2016


the declaration in of plen (also scope and dad_status) as an int in 
enumIPv6Interfaces would appear to be done to align with
its use in fscanf, even though it is a two character conversion.
So would it not be more appropriate to cast it as a short when passed to 
addif ?

the name plen would also convey a variable containing a length, but that 
doesn't appear to be the purpose of plen.
a more appropriate name would be more informative in the code

regards
Mark


On 11/05/2016 09:50, Chris Hegarty wrote:
> Hi Christoph,
>
> On 11 May 2016, at 08:43, Dmitry Samersoff <dmitry.samersoff at oracle.com> wrote:
>
>>> ...
>>> bugreport: https://bugs.openjdk.java.net/browse/JDK-8156521
>>>
>>> webrev: http://cr.openjdk.java.net/~clanger/webrevs/8156521.0/
> I think this is mainly fine, and good to have such cleanup in this area.
>
> I agree with the replacement of strcpy with strncpy, but I think we should
> explicitly null terminate in case the src is greater or equal to the dst buffer
> size. This is done elsewhere in this file too, e.g.
>
>     strncpy(buf, input, sizeof(buf) - 1);
>     buf[sizeof(buf) - 1] = '\0';
>
>
>>> Apart from quite a few whitespace changes to clean up the coding, I went
>>> through and replaced all occurences of strcpy with strncpy as this was a
>>> finding of a code scanner that we used. Also in function
>>> “enumIPv6Interfaces” for Linux the local variable plen was changed from
>>> int to short.
> Why was this done for plen specifically, and not scope, or others ?
>
> -Chris.



More information about the net-dev mailing list