From 8c1f30739e39c7b9ddd73b4d24e46409914fc3e1 Mon Sep 17 00:00:00 2001 From: Logan Gunthorpe Date: Wed, 29 Apr 2026 15:41:36 -0600 Subject: [PATCH 1/2] examples/iopf: Make pdev static Sparse warns: ../examples/iopf.c:46:24: warning: symbol 'pdev' was not declared. Should it be static? Fix this warning by making pdev static. Signed-off-by: Logan Gunthorpe --- examples/iopf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/iopf.c b/examples/iopf.c index 1e3e8f1e..fcd428e8 100644 --- a/examples/iopf.c +++ b/examples/iopf.c @@ -43,7 +43,7 @@ static struct opt_table opts[] = { OPT_ENDTABLE, }; -struct vfio_pci_device pdev; +static struct vfio_pci_device pdev; int main(int argc, char **argv) { From 7897a121f9f131dc40f462ab4b34f9c9e86e2b96 Mon Sep 17 00:00:00 2001 From: Logan Gunthorpe Date: Wed, 29 Apr 2026 15:46:22 -0600 Subject: [PATCH 2/2] examples/iopf: Use proper endianness conversion helpers Sparse reports several warnings in iopf: ../examples/iopf.c:92:42: warning: incorrect type in argument 2 ../examples/iopf.c:92:42: expected restricted leint64_t [usertype] v ../examples/iopf.c:92:42: got unsigned long [usertype] iova ../examples/iopf.c:93:38: warning: incorrect type in argument 2 ../examples/iopf.c:93:38: expected restricted leint32_t [usertype] v ../examples/iopf.c:93:38: got int ../examples/iopf.c:109:27: warning: restricted leint32_t degrades to integer ../examples/iopf.c:114:38: warning: incorrect type in argument 2 ../examples/iopf.c:114:38: expected restricted leint32_t [usertype] v ../examples/iopf.c:114:38: got int ../examples/iopf.c:116:27: warning: restricted leint32_t degrades to integer Fix these by adding proper cpu_to_lexx() and lexx_to_cpu() conversions. Signed-off-by: Logan Gunthorpe --- examples/iopf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/iopf.c b/examples/iopf.c index fcd428e8..99c316e5 100644 --- a/examples/iopf.c +++ b/examples/iopf.c @@ -89,8 +89,8 @@ int main(int argc, char **argv) memset(vaddr, 0x42, 0x1000); - mmio_lh_write64(bar0 + REG_ADDR, iova); - mmio_write32(bar0 + REG_CMD, 0x3); + mmio_lh_write64(bar0 + REG_ADDR, cpu_to_le64(iova)); + mmio_write32(bar0 + REG_CMD, cpu_to_le32(0x3)); /* wait for page fault */ while (read(fq.fault_fd, &pgfault, sizeof(pgfault)) == 0) @@ -106,14 +106,14 @@ int main(int argc, char **argv) if (write(fq.fault_fd, &pgresp, sizeof(pgresp)) < 0) err(1, "failed to write page response"); - while (mmio_read32(bar0 + REG_CMD) & 0x1) + while (le32_to_cpu(mmio_read32(bar0 + REG_CMD)) & 0x1) ; memset(vaddr, 0x0, 0x1000); - mmio_write32(bar0 + REG_CMD, 0x1); + mmio_write32(bar0 + REG_CMD, cpu_to_le32(0x1)); - while (mmio_read32(bar0 + REG_CMD) & 0x1) + while (le32_to_cpu(mmio_read32(bar0 + REG_CMD)) & 0x1) ; for (int i = 0; i < 0x1000; i++) {