git: d722901fa3a2 - main - ddb: Fix format string errors in db_pprint.c

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 22 Mar 2024 06:14:30 UTC
The branch main has been updated by markj:

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

commit d722901fa3a258d879ce894242a926961a964107
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-03-22 06:11:03 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-03-22 06:11:03 +0000

    ddb: Fix format string errors in db_pprint.c
    
    For some reason, db_expr_t is defined as "long" on 64-bit platforms and
    "int" on others.  When printing values of this type, simply cast them to
    long to suppress compilation errors on 32-bit systems.
    
    Reviewed by:    bnovkov
    Fixes:  c21bc6f3c242 ("ddb: Add CTF-based pretty printing")
---
 sys/ddb/db_pprint.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/ddb/db_pprint.c b/sys/ddb/db_pprint.c
index dc7582864957..aae3d698e8ec 100644
--- a/sys/ddb/db_pprint.c
+++ b/sys/ddb/db_pprint.c
@@ -72,7 +72,7 @@ db_pprint_int(db_addr_t addr, struct ctf_type_v3 *type, u_int depth)
 		return;
 	}
 	db_printf("0x%lx",
-	    db_get_value(addr, (bits / 8) ? (bits / 8) : 1, sign));
+	    (long)db_get_value(addr, (bits / 8) ? (bits / 8) : 1, sign));
 }
 
 /*
@@ -226,9 +226,9 @@ db_pprint_enum(db_addr_t addr, struct ctf_type_v3 *type, u_int depth)
 		if (val == ep->cte_value) {
 			valname = db_ctf_stroff_to_str(&sym_data, ep->cte_name);
 			if (valname != NULL)
-				db_printf("%s (0x%lx)", valname, val);
+				db_printf("%s (0x%lx)", valname, (long)val);
 			else
-				db_printf("(0x%lx)", val);
+				db_printf("(0x%lx)", (long)val);
 			break;
 		}
 	}
@@ -273,9 +273,9 @@ db_pprint_ptr(db_addr_t addr, struct ctf_type_v3 *type, u_int depth)
 		name = db_ctf_stroff_to_str(&sym_data, ref_type->ctt_name);
 		db_indent = depth;
 		if (name != NULL)
-			db_printf("(%s%s *) 0x%lx", qual, name, val);
+			db_printf("(%s%s *) 0x%lx", qual, name, (long)val);
 		else
-			db_printf("0x%lx", val);
+			db_printf("0x%lx", (long)val);
 	}
 }
 
@@ -305,7 +305,7 @@ db_pprint_type(db_addr_t addr, struct ctf_type_v3 *type, u_int depth)
 	case CTF_K_FUNCTION:
 	case CTF_K_FLOAT:
 		db_indent = depth;
-		db_iprintf("0x%lx", addr);
+		db_iprintf("0x%lx", (long)addr);
 		break;
 	case CTF_K_POINTER:
 		db_pprint_ptr(addr, type, depth);