From 35b4acad2f1f7ba87eb9e0c7276ef8eef55b4a9c Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 2 Mar 2023 10:56:44 -0700 Subject: [PATCH] kboot: Use MIN instead of min MIN works for any type, while min() is only for integers. So we were rounding down to 0 since that's the size of 4GB truncated to an int. Sponsored by: Netflix --- stand/kboot/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stand/kboot/main.c b/stand/kboot/main.c index e01507323bad..849ad46add6c 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -344,10 +344,11 @@ get_phys_buffer(vm_offset_t dest, const size_t len, void **buf) /* how much space does this segment have */ sz = space_avail(dest); /* Clip to 45% of available memory (need 2 copies) */ - sz = min(sz, rounddown2(mem_avail * 45 / 100, SEGALIGN)); + sz = MIN(sz, rounddown2(mem_avail * 45 / 100, SEGALIGN)); + printf("limit to 45%% of mem_avail %zd\n", sz); /* And only use 95% of what we can allocate */ - sz = min(sz, rounddown2( - (commit_limit - committed_as) * 95 / 100, SEGALIGN)); + sz = MIN(sz, + rounddown2((commit_limit - committed_as) * 95 / 100, SEGALIGN)); printf("Allocating %zd MB for first segment\n", sz >> 20); }