git: 7b5cb32fca26 - main - kern: physmem: properly cast %jx arguments to uintmax_t

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Mon, 20 Feb 2023 22:13:27 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=7b5cb32fca26428b8c0df98f9c58444557f808ae

commit 7b5cb32fca26428b8c0df98f9c58444557f808ae
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-02-20 22:11:44 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-02-20 22:12:55 +0000

    kern: physmem: properly cast %jx arguments to uintmax_t
    
    While we're here, slap prfunc with a __printflike to get compiler
    checking on args to catch silly mistakes like this.
    
    Reported by:    jrtc27
---
 sys/kern/subr_physmem.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/kern/subr_physmem.c b/sys/kern/subr_physmem.c
index d371e1e166c5..a53d2cb879eb 100644
--- a/sys/kern/subr_physmem.c
+++ b/sys/kern/subr_physmem.c
@@ -120,7 +120,7 @@ panic(const char *fmt, ...)
  * db_printf).
  */
 static void
-physmem_dump_tables(int (*prfunc)(const char *, ...))
+physmem_dump_tables(int (*prfunc)(const char *, ...) __printflike(1, 2))
 {
 	size_t i;
 	int flags;
@@ -149,10 +149,12 @@ physmem_dump_tables(int (*prfunc)(const char *, ...))
 #ifdef DEBUG
 	prfunc("Avail lists:\n");
 	for (i = 0; phys_avail[i] != 0; ++i) {
-		prfunc("  phys_avail[%d] 0x%08jx\n", i, phys_avail[i]);
+		prfunc("  phys_avail[%d] 0x%08jx\n", i,
+		    (uintmax_t)phys_avail[i]);
 	}
 	for (i = 0; dump_avail[i] != 0; ++i) {
-		prfunc("  dump_avail[%d] 0x%08jx\n", i, dump_avail[i]);
+		prfunc("  dump_avail[%d] 0x%08jx\n", i,
+		    (uintmax_t)dump_avail[i]);
 	}
 #endif
 }