Re: [PATCH] builtin/gc: improve total_ram calculation for HAVE_BSD_SYSCTL
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jul 2, 2025, 15:23 UTC
- Message-ID
- <aGVO3ej7bEo5swih@pks.im>
- In-Reply-To
- <20250702144244.43858-1-carenas@gmail.com>
On Wed, Jul 02, 2025 at 07:42:44AM -0700, Carlo Marcelo Arenas Belón wrote:
Show 6 quoted lines
> In BSD systems other than macOS, since 9806f5a7bf (gc --auto: > exclude base pack if not enough mem to "repack -ad", 2018-04-15), > sysctl() use HW_PHYSMEM with the wrong size for the target. > > Use the correct type for physical_memory on each option and make > sure it is initialized, so it is safe to use even if sysctl() fails.
We don't use it though when sysctl(3) fails, do we? We only return `physical_memory` in case sysctl(3) returned zero, which indicates success. Which raises the question whether that function ever returns a zero value without writing the value to the pointer.
Not that it would really hurt to initialize the value, but I found this explanation to be puzzling.
> While at it, add a cast to the returned value for consistency.
Okay. It's not really needed, but other branches do it, as well.
Patrick