[12] RFR: 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
Simon Tooke
stooke at redhat.com
Mon Dec 10 18:57:08 UTC 2018
This small patch fixes some simple warnings in Hotspot 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)
For xmlstream.cpp, this is actually a small inefficiency, as the null
byte is immediately overwritten; but it makes GCC happy.
Bug: https://bugs.openjdk.java.net/browse/JDK-8214777
Webrev:
http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214777/02/webrev/
More information about the hotspot-runtime-dev
mailing list