git: 124e46735e07 - main - ntb: Use uintmax_t casts and %j to print physical addresses.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 28 Sep 2022 21:06:38 UTC
The branch main has been updated by jhb:

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

commit 124e46735e07037afafbf0caa097faafb09c7329
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-09-28 20:56:31 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-09-28 20:56:31 +0000

    ntb: Use uintmax_t casts and %j to print physical addresses.
    
    This fixes -Wint-to-pointer-cast errors with GCC when compiling on
    i386 where physical addresses are not the same size as pointers.
    
    Reviewed by:    mav, imp
    Differential Revision:  https://reviews.freebsd.org/D36751
---
 sys/dev/ntb/ntb_hw/ntb_hw_amd.c   |  6 +++---
 sys/dev/ntb/ntb_hw/ntb_hw_intel.c | 14 ++++++++------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_amd.c b/sys/dev/ntb/ntb_hw/ntb_hw_amd.c
index 94cfba2bfe72..eef4f7ca463a 100644
--- a/sys/dev/ntb/ntb_hw/ntb_hw_amd.c
+++ b/sys/dev/ntb/ntb_hw/ntb_hw_amd.c
@@ -1112,10 +1112,10 @@ static void
 print_map_success(struct amd_ntb_softc *ntb, struct amd_ntb_pci_bar_info *bar,
     const char *kind)
 {
-	amd_ntb_printf(0, "Mapped BAR%d v:[%p-%p] p:[%p-%p] (0x%jx bytes) (%s)\n",
+	amd_ntb_printf(0, "Mapped BAR%d v:[%p-%p] p:[0x%jx-0x%jx] (0x%jx bytes) (%s)\n",
 	    PCI_RID2BAR(bar->pci_resource_id), bar->vbase,
-	    (char *)bar->vbase + bar->size - 1, (void *)bar->pbase,
-	    (void *)(bar->pbase + bar->size - 1), (uintmax_t)bar->size, kind);
+	    (char *)bar->vbase + bar->size - 1, (uintmax_t)bar->pbase,
+	    (uintmax_t)(bar->pbase + bar->size - 1), (uintmax_t)bar->size, kind);
 }
 
 static void
diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
index 774bb14fea0f..a6c71935665b 100644
--- a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
+++ b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
@@ -925,10 +925,10 @@ print_map_success(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar,
 {
 
 	device_printf(ntb->device,
-	    "Mapped BAR%d v:[%p-%p] p:[%p-%p] (0x%jx bytes) (%s)\n",
+	    "Mapped BAR%d v:[%p-%p] p:[0x%jx-0x%jx] (0x%jx bytes) (%s)\n",
 	    PCI_RID2BAR(bar->pci_resource_id), bar->vbase,
 	    (char *)bar->vbase + bar->size - 1,
-	    (void *)bar->pbase, (void *)(bar->pbase + bar->size - 1),
+	    (uintmax_t)bar->pbase, (uintmax_t)(bar->pbase + bar->size - 1),
 	    (uintmax_t)bar->size, kind);
 }
 
@@ -1012,19 +1012,21 @@ map_memory_window_bar(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar)
 	if (rc == 0) {
 		bar->map_mode = mapmode;
 		device_printf(ntb->device,
-		    "Marked BAR%d v:[%p-%p] p:[%p-%p] as "
+		    "Marked BAR%d v:[%p-%p] p:[0x%jx-0x%jx] as "
 		    "%s.\n",
 		    PCI_RID2BAR(bar->pci_resource_id), bar->vbase,
 		    (char *)bar->vbase + bar->size - 1,
-		    (void *)bar->pbase, (void *)(bar->pbase + bar->size - 1),
+		    (uintmax_t)bar->pbase,
+		    (uintmax_t)(bar->pbase + bar->size - 1),
 		    intel_ntb_vm_memattr_to_str(mapmode));
 	} else
 		device_printf(ntb->device,
-		    "Unable to mark BAR%d v:[%p-%p] p:[%p-%p] as "
+		    "Unable to mark BAR%d v:[%p-%p] p:[0x%jx-0x%jx] as "
 		    "%s: %d\n",
 		    PCI_RID2BAR(bar->pci_resource_id), bar->vbase,
 		    (char *)bar->vbase + bar->size - 1,
-		    (void *)bar->pbase, (void *)(bar->pbase + bar->size - 1),
+		    (uintmax_t)bar->pbase,
+		    (uintmax_t)(bar->pbase + bar->size - 1),
 		    intel_ntb_vm_memattr_to_str(mapmode), rc);
 		/* Proceed anyway */
 	return (0);