pci: use z specifier to format size_t
authorStephen Hemminger <stephen@networkplumber.org>
Thu, 15 Feb 2018 22:25:49 +0000 (14:25 -0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 4 Apr 2018 11:43:33 +0000 (13:43 +0200)
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 <stephen@networkplumber.org>
lib/librte_pci/rte_pci.c

index 1a6d748..530738d 100644 (file)
@@ -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",