On Fri, 27 Oct 2023 08:38:02 GMT, Johan Sjölen <jsjo...@openjdk.org> wrote:

>> Thomas Stuefe has updated the pull request with a new target base due to a 
>> merge or a rebase. The pull request now contains four commits:
>> 
>>  - Merge master and solve merge conflicts
>>  - small fixes
>>  - start from VM op; show more thread details
>>  - start
>
> src/hotspot/os/linux/memMapPrinter_linux.cpp line 39:
> 
>> 37:   char dev[20 + 1];
>> 38:   char inode[20 + 1];
>> 39:   char filename[1024 + 1];
> 
> Maybe use `PATH_MAX` here? Potentially +1 to account for null byte.

That is surprisingly tricky since there is no way to specify variable sizes 
with scanf, unlike printf. 

One could rely on PATH_MAX being a pure numerical ("4096") and assemble the 
format string with preprocessor magic, but that falls apart if PATH_MAX is e.g. 
a constant. 

One could build up the format string dynamically at runtime, but that will 
trigger warnings in code linters and possibly when building since the format 
string is supposed to be a literal.

Also, the PATH_MAX size is pretty arbitrary. Paths can get infinitely long with 
nested links. So there is no safe limit anyway. May just as well keep 1024 
then, since that should be enough for 99% of cases.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16301#discussion_r1374420720

Reply via email to