On Wed, 1 Apr 2026 04:45:02 GMT, David Holmes <[email protected]> wrote:

>> Roman Kennke has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Improve truncation code on BSD and Windows, add comment to Linux
>
> src/hotspot/os/bsd/os_bsd.cpp line 2265:
> 
>> 2263:     size_t name_len = MIN2(len, sizeof(buf) - 7);
>> 2264:     memcpy(buf + 6, name, name_len);
>> 2265:     buf[6 + name_len] = '\0';
> 
> Suggestion:
> 
>     const char* prefix = "Java: ";
>     const size_t prefix_len = strlen(prefix);
>     memcpy(buf, "Java: ", prefix_len);
>     size_t name_len = MIN2(len, sizeof(buf) - (prefix_len + 1));
>     memcpy(buf + prefix_len, name, name_len);
>     buf[prefix_len + name_len] = '\0';

Actually can't we pre-init the buffer with the prefix directly:

char buf[MAXTHREADNAMESIZE] = { 'J', 'a', 'v', 'a', ':', " "};

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/30374#discussion_r3019739650

Reply via email to