Skip to content

Commit 35c9f02

Browse files
committed
Improve commenting in os_linux.cpp
1 parent 1921aee commit 35c9f02

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/hotspot/os/linux/os_linux.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,12 @@ bool os::free_swap_space(size_t& value) {
332332
}
333333
size_t host_free_swap_val = MIN2(total_swap_space, host_free_swap);
334334
if (OSContainer::is_containerized()) {
335+
// We are using jlong for various delta calculations since negative values
336+
// might be out of range for ssize_t (which has range [-1,SSIZE_MAX])
337+
335338
ssize_t mem_swap_limit = OSContainer::memory_and_swap_limit_in_bytes();
336339
ssize_t mem_limit = OSContainer::memory_limit_in_bytes();
337340
if (mem_swap_limit >= 0 && mem_limit >= 0) {
338-
// using jlong as that is potentially out of range for ssize_t
339341
jlong delta_limit = mem_swap_limit - mem_limit;
340342
if (delta_limit <= 0) {
341343
value = 0;
@@ -344,10 +346,8 @@ bool os::free_swap_space(size_t& value) {
344346
ssize_t mem_swap_usage = OSContainer::memory_and_swap_usage_in_bytes();
345347
ssize_t mem_usage = OSContainer::memory_usage_in_bytes();
346348
if (mem_swap_usage > 0 && mem_usage > 0) {
347-
// using jlong as that is potentially out of range for ssize_t
348349
jlong delta_usage = mem_swap_usage - mem_usage;
349350
if (delta_usage >= 0) {
350-
// using jlong as that is potentially out of range for ssize_t
351351
jlong free_swap = delta_limit - delta_usage;
352352
value = free_swap >= 0 ? static_cast<size_t>(free_swap) : 0;
353353
return true;

0 commit comments

Comments
 (0)