RFR: 8357086: os::xxx functions returning memory size should return size_t [v2]

Anton Artemov duke at openjdk.org
Wed May 28 11:11:55 UTC 2025


On Wed, 28 May 2025 09:47:20 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8357086: Addressed reviewer's comments.
>
> src/hotspot/os/linux/os_linux.cpp line 298:
> 
>> 296: }
>> 297: 
>> 298: static size_t host_free_swap() {
> 
> It is not obvious to me that callers of this are reacting properly when the return value goes from signed to unsigned. I'm thinking about code in os::free_swap_space below:
> 
> jlong host_free_swap_val = MIN2(os::total_swap_space(), host_free_swap());
> 
> How does MIN2 react to -1 vs 0xFFFFFFFFFFFFFFFF

You are right, host_free_swap should return a signed counterpart of size_t, i.e. ptrdiff_t, then negative error value is handled correctly. Addressed in the latest commit.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25450#discussion_r2111580829


More information about the hotspot-dev mailing list