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

Simon Tooke stooke at redhat.com
Mon Dec 10 15:25:20 UTC 2018


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/


More information about the hotspot-jfr-dev mailing list