From: Stephen Hemminger Date: Thu, 15 Feb 2018 22:25:49 +0000 (-0800) Subject: pci: use z specifier to format size_t X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=97d4aaffa7e5eb2829549bbecc2959f941f4a088;p=dpdk.git 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 --- 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",