diff options
author | Warner Losh <imp@FreeBSD.org> | 2023-03-02 17:56:44 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2023-03-02 18:12:10 +0000 |
commit | 35b4acad2f1f7ba87eb9e0c7276ef8eef55b4a9c (patch) | |
tree | befb573fb61ab5b11cad0d120e441a1e472bab25 | |
parent | 3a616b10d8f7bb0f1af7d6a971bdfbabdfecd896 (diff) | |
download | src-35b4acad2f1f7ba87eb9e0c7276ef8eef55b4a9c.tar.gz src-35b4acad2f1f7ba87eb9e0c7276ef8eef55b4a9c.zip |
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
-rw-r--r-- | stand/kboot/main.c | 7 |
1 files 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); } |