RFR: 8345012: os::build_agent_function_name potentially wastes a byte when allocating the buffer
David Holmes
dholmes at openjdk.org
Wed Nov 27 00:50:11 UTC 2024
This is a minor issue noticed in the review of JEP 479. The calculations of the buffer length always do `+2` to allow for an optional underscore plus the terminator. A solution was suggested in that review (which I initially used) but I've instead opted for a solution where `name_len` always reflects the actual length of the lib name - otherwise we need to subtract the 1 again when doing the `strncat`. I also made the need for the underscore explicit.
As the same code is used in os_posix.cpp both versions were made consistent. The only difference between them is the Windows version has to check for a drive specifier. I toyed with combining them into a shared version with a Windows-specific chunk, but opted for the simpler change. I can revisit that is people have strong opinions.
Testing
- tiers 1-4
Thanks
-------------
Commit messages:
- Rework things so that `name_len` is always actually the length of the lib name, and make using
- Fix up strncat length
- Same changes for os_posix and align code between the versions
- 8345012: os::build_agent_function_name potentially wastes a byte when allocating the buffer
Changes: https://git.openjdk.org/jdk/pull/22404/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22404&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8345012
Stats: 15 lines in 2 files changed: 6 ins; 0 del; 9 mod
Patch: https://git.openjdk.org/jdk/pull/22404.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/22404/head:pull/22404
PR: https://git.openjdk.org/jdk/pull/22404
More information about the hotspot-runtime-dev
mailing list