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

Stefan Karlsson stefank at openjdk.org
Thu Jun 12 15:05:30 UTC 2025


On Thu, 12 Jun 2025 08:39:30 GMT, Anton Artemov <duke at openjdk.org> wrote:

>> Hmm. Isn't 257 redundant because we already check for this on line 241 and the code between should never set the `avail_mem` to `-1`. Maybe this code needs some extra scrutiny as well (as a follow-up)
>
> Thanks for spotting this. Line 243 definitely needs treatment as well as line 258. Addressed in the latest commit. 
> 
> Line 257 does not look redundant to me. `avail_mem` could be set to large error value (cast from -1) on line 240, then lines between 246 and 256 can actually left untouched if something went wrong with reading meminfo file. Then we need to check if we still have an error value in `avail_mem`, and if so, use the one returned by `free_memory()`.

I agree. (Though I still think this method could be improved to just use one -1 check. Obviously not in this PR).

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

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


More information about the hotspot-dev mailing list