Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2023 18:18:32 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 35b4acad2f1f - main - kboot: Use MIN instead of min
Message-ID:  <202303021818.322IIWLN035410@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=35b4acad2f1f7ba87eb9e0c7276ef8eef55b4a9c

commit 35b4acad2f1f7ba87eb9e0c7276ef8eef55b4a9c
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-03-02 17:56:44 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-03-02 18:12:10 +0000

    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);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303021818.322IIWLN035410>