Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
13
-
b09
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8230714 | 11.0.6 | Mikael Vidstedt | P4 | Resolved | Fixed | b01 |
JDK-8240405 | openjdk8u262 | Mikael Vidstedt | P4 | Resolved | Fixed | team |
Description
GCC 8.2 is producing warnings like this:
In function 'char* copy_path(const char*)',
inlined from 'void JfrChunkState::set_path(const char*)' at src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:115:22:
src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:103:10: error: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
strncpy(new_path, path, path_len);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Basically, gcc is pointing out that the resulting string is not going to be terminated. This is fine from a functional perspective, because in all cases the very next thing we do is add the necessary nul termination, but having strncpy produce a nul terminated string has the benefit of not having to terminate it explicitly, and, of course, silence the warnings.
In function 'char* copy_path(const char*)',
inlined from 'void JfrChunkState::set_path(const char*)' at src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:115:22:
src/hotspot/share/jfr/recorder/repository/jfrChunkState.cpp:103:10: error: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
strncpy(new_path, path, path_len);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Basically, gcc is pointing out that the resulting string is not going to be terminated. This is fine from a functional perspective, because in all cases the very next thing we do is add the necessary nul termination, but having strncpy produce a nul terminated string has the benefit of not having to terminate it explicitly, and, of course, silence the warnings.
Attachments
Issue Links
- backported by
-
JDK-8230714 Make jfr strncpy uses GCC 8.x friendly
- Resolved
-
JDK-8240405 Make jfr strncpy uses GCC 8.x friendly
- Resolved
-
JDK-8243909 Make jfr strncpy uses GCC 8.x friendly
- Resolved
- relates to
-
JDK-8239140 Backport JFR to OpenJDK 8
- Resolved
-
JDK-8213153 Clean up GCC 8 errors
- Closed