RFR: JDK-8267930: Refine code for loading hsdis library [v3]
Yasumasa Suenaga
ysuenaga at openjdk.java.net
Mon May 31 13:11:28 UTC 2021
On Mon, 31 May 2021 12:40:50 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> code for loading hsdis library is redundant, this is to simplify it.
>
> Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:
>
> fix typo
src/hotspot/share/compiler/disassembler.cpp line 761:
> 759: if (offset + strlen(hsdis_library_name) + strlen(os::dll_file_extension()) < buflen) {
> 760: strcpy(&buf[offset], hsdis_library_name);
> 761: strcat(&buf[offset], os::dll_file_extension());
I think we can more simplify these code as following:
int sz = buflen - offset;
int n_written = snprintf(&buf[offset], sz, "%s%s", hsdis_library_name, os::dll_file_extension());
if (n_written < sz) {
`snprintf()` returns _`size`_ or more bytes if the buffer is not enough.
https://man7.org/linux/man-pages/man3/printf.3.html
-------------
PR: https://git.openjdk.java.net/jdk/pull/4260
More information about the hotspot-compiler-dev
mailing list