From 97d4aaffa7e5eb2829549bbecc2959f941f4a088 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 15 Feb 2018 14:25:49 -0800 Subject: [PATCH] pci: use z specifier to format size_t This addresses potential issues where size_t and off_t can vary on some platforms. For size_t the best way to format the value is to use the z modifier to printf. For off_t need to cast to long long to handle 64 bit offset on 32 bit platforms. Signed-off-by: Stephen Hemminger --- lib/librte_pci/rte_pci.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c index 1a6d748568..530738dbdf 100644 --- a/lib/librte_pci/rte_pci.c +++ b/lib/librte_pci/rte_pci.c @@ -155,9 +155,10 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE, MAP_SHARED | additional_flags, fd, offset); if (mapaddr == MAP_FAILED) { - RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n", - __func__, fd, requested_addr, - (unsigned long)size, (unsigned long)offset, + RTE_LOG(ERR, EAL, + "%s(): cannot mmap(%d, %p, 0x%zx, 0x%llx): %s (%p)\n", + __func__, fd, requested_addr, size, + (unsigned long long)offset, strerror(errno), mapaddr); } else RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr); @@ -174,8 +175,8 @@ pci_unmap_resource(void *requested_addr, size_t size) /* Unmap the PCI memory resource of device */ if (munmap(requested_addr, size)) { - RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n", - __func__, requested_addr, (unsigned long)size, + RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, %#zx): %s\n", + __func__, requested_addr, size, strerror(errno)); } else RTE_LOG(DEBUG, EAL, " PCI memory unmapped at %p\n", -- 2.20.1