git: 661bd70bd72d - main - DMAR: clean up warnings about write-only variables

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 21 Oct 2021 18:41:36 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=661bd70bd72d510ad7153df530d55a300046d619

commit 661bd70bd72d510ad7153df530d55a300046d619
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-10-21 17:23:45 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-10-21 18:40:46 +0000

    DMAR: clean up warnings about write-only variables
    
    For some of them, used only when KTR or KMSAN are configured, apply
    __unused attribute directly.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/dev/iommu/busdma_iommu.c  | 5 +++--
 sys/dev/iommu/iommu_gas.c     | 4 ++--
 sys/x86/iommu/intel_ctx.c     | 4 ++--
 sys/x86/iommu/intel_drv.c     | 2 --
 sys/x86/iommu/intel_idpgtbl.c | 3 +--
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c
index 75835d7484e5..d32beee19be7 100644
--- a/sys/dev/iommu/busdma_iommu.c
+++ b/sys/dev/iommu/busdma_iommu.c
@@ -398,7 +398,8 @@ iommu_bus_dma_tag_set_domain(bus_dma_tag_t dmat)
 static int
 iommu_bus_dma_tag_destroy(bus_dma_tag_t dmat1)
 {
-	struct bus_dma_tag_iommu *dmat, *dmat_copy, *parent;
+	struct bus_dma_tag_iommu *dmat, *parent;
+	struct bus_dma_tag_iommu *dmat_copy __unused;
 	int error;
 
 	error = 0;
@@ -920,7 +921,7 @@ static void
 iommu_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map1,
     bus_dmasync_op_t op)
 {
-	struct bus_dmamap_iommu *map;
+	struct bus_dmamap_iommu *map __unused;
 
 	map = (struct bus_dmamap_iommu *)map1;
 	kmsan_bus_dmamap_sync(&map->kmsan_mem, op);
diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c
index ae54f41953c8..c4faebec9d08 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -354,7 +354,7 @@ iommu_gas_match_one(struct iommu_gas_match_args *a, iommu_gaddr_t beg,
 static void
 iommu_gas_match_insert(struct iommu_gas_match_args *a)
 {
-	bool found;
+	bool found __diagused;
 
 	/*
 	 * The prev->end is always aligned on the page size, which
@@ -475,7 +475,7 @@ iommu_gas_alloc_region(struct iommu_domain *domain, struct iommu_map_entry *entr
     u_int flags)
 {
 	struct iommu_map_entry *next, *prev;
-	bool found;
+	bool found __diagused;
 
 	IOMMU_DOMAIN_ASSERT_LOCKED(domain);
 
diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c
index dc8ee4e2f9a2..34730306000b 100644
--- a/sys/x86/iommu/intel_ctx.c
+++ b/sys/x86/iommu/intel_ctx.c
@@ -521,7 +521,7 @@ dmar_get_ctx_for_dev1(struct dmar_unit *dmar, device_t dev, uint16_t rid,
 {
 	struct dmar_domain *domain, *domain1;
 	struct dmar_ctx *ctx, *ctx1;
-	struct iommu_unit *unit;
+	struct iommu_unit *unit __diagused;
 	dmar_ctx_entry_t *ctxp;
 	struct sf_buf *sf;
 	int bus, slot, func, error;
@@ -904,7 +904,7 @@ dmar_domain_unload(struct dmar_domain *domain,
 	struct dmar_unit *unit;
 	struct iommu_domain *iodom;
 	struct iommu_map_entry *entry, *entry1;
-	int error;
+	int error __diagused;
 
 	iodom = DOM2IODOM(domain);
 	unit = DOM2DMAR(domain);
diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c
index a19084eb3e66..0b470d7bbf7a 100644
--- a/sys/x86/iommu/intel_drv.c
+++ b/sys/x86/iommu/intel_drv.c
@@ -762,7 +762,6 @@ dmar_find_by_scope(int dev_domain, int dev_busno,
 struct dmar_unit *
 dmar_find(device_t dev, bool verbose)
 {
-	device_t dmar_dev;
 	struct dmar_unit *unit;
 	const char *banner;
 	int i, dev_domain, dev_busno, dev_path_len;
@@ -774,7 +773,6 @@ dmar_find(device_t dev, bool verbose)
 	    devclass_find("pci"))
 		return (NULL);
 
-	dmar_dev = NULL;
 	dev_domain = pci_get_domain(dev);
 	dev_path_len = dmar_dev_depth(dev);
 	ACPI_DMAR_PCI_PATH dev_path[dev_path_len];
diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c
index 2346640ce015..be421fee7aa9 100644
--- a/sys/x86/iommu/intel_idpgtbl.c
+++ b/sys/x86/iommu/intel_idpgtbl.c
@@ -425,7 +425,7 @@ domain_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
 {
 	dmar_pte_t *pte;
 	struct sf_buf *sf;
-	iommu_gaddr_t pg_sz, base1, size1;
+	iommu_gaddr_t pg_sz, base1;
 	vm_pindex_t pi, c, idx, run_sz;
 	int lvl;
 	bool superpage;
@@ -433,7 +433,6 @@ domain_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
 	DMAR_DOMAIN_ASSERT_PGLOCKED(domain);
 
 	base1 = base;
-	size1 = size;
 	flags |= IOMMU_PGF_OBJL;
 	TD_PREP_PINNED_ASSERT;