RFR: 8214776: Avoid GCC 8.X strncpy() errors in JFR code

Severin Gehwolf sgehwolf at redhat.com
Tue Dec 11 16:38:18 UTC 2018


On Tue, 2018-12-11 at 11:29 -0500, Simon Tooke wrote:
> On 2018-12-11 11:06 a.m., Simon Tooke wrote:
> > On 2018-12-11 8:47 a.m., Severin Gehwolf wrote:
> > > Hi Simon,
> > > 
> > > On Mon, 2018-12-10 at 10:25 -0500, Simon Tooke wrote:
> > > > This small patch fixes some simple warnings in JFR code, found by GCC 8.1
> > > > Essentially, any code sequence of the pattern
> > > > 
> > > >     int l = strlen(somestring)
> > > >     char* buffer = malloc(l + 1)
> > > >     strncpy(buffer, somestring, l)
> > > >     buffer[l] = 0
> > > > 
> > > > is replaced by
> > > > 
> > > >     int len = strlen(somestring)
> > > >     char* buffer = malloc(len + 1)
> > > >     strncpy(buffer, somestring, len + 1)
> > > > 
> > > > Bug: https://bugs.openjdk.java.net/browse/JDK-8214776
> > > > Webrev:
> > > > http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214776/02/webrev/
> 
> Revised webrev:
> 
> http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214776/03/webrev/

This looks good to me.

Thanks,
Severin



More information about the hotspot-jfr-dev mailing list