git: 19782e5bef34 - main - ibcore: Mark write-only variables

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Wed, 12 Jun 2024 15:51:03 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=19782e5bef3403a6ed65d46653f2e70f81dced37

commit 19782e5bef3403a6ed65d46653f2e70f81dced37
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-06-12 13:04:45 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-06-12 13:04:45 +0000

    ibcore: Mark write-only variables
    
    Some LinuxKPI lock macros pass need a flags field passed in. This is
    written to but never read from so gcc complains.
    
    Fix this by marking the flags variables as unused to quieten the
    compiler.
    
    Reviewed by:    brooks (earlier version), kib
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D45303
---
 sys/ofed/drivers/infiniband/core/ib_cache.c | 16 ++++++++--------
 sys/ofed/drivers/infiniband/core/ib_cm.c    |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/ofed/drivers/infiniband/core/ib_cache.c b/sys/ofed/drivers/infiniband/core/ib_cache.c
index b170f2b637f9..d2cc680796ef 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cache.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cache.c
@@ -465,7 +465,7 @@ static int _ib_cache_gid_table_find(struct ib_device *ib_dev,
 	struct ib_gid_table *table;
 	u8 p;
 	int local_index;
-	unsigned long flags;
+	unsigned long flags __writeonly;
 
 	for (p = 0; p < ib_dev->phys_port_cnt; p++) {
 		table = ports_table[p];
@@ -514,7 +514,7 @@ int ib_find_cached_gid_by_port(struct ib_device *ib_dev,
 	unsigned long mask = GID_ATTR_FIND_MASK_GID |
 			     GID_ATTR_FIND_MASK_GID_TYPE;
 	struct ib_gid_attr val = {.ndev = ndev, .gid_type = gid_type};
-	unsigned long flags;
+	unsigned long flags __writeonly;
 
 	if (!rdma_is_port_valid(ib_dev, port))
 		return -ENOENT;
@@ -570,7 +570,7 @@ static int ib_cache_gid_find_by_filter(struct ib_device *ib_dev,
 	struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
 	struct ib_gid_table *table;
 	unsigned int i;
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	bool found = false;
 
 	if (!ports_table)
@@ -879,7 +879,7 @@ int ib_get_cached_gid(struct ib_device *device,
 		      struct ib_gid_attr *gid_attr)
 {
 	int res;
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	struct ib_gid_table **ports_table = device->cache.gid_cache;
 	struct ib_gid_table *table = ports_table[port_num - rdma_start_port(device)];
 
@@ -929,7 +929,7 @@ int ib_get_cached_pkey(struct ib_device *device,
 		       u16              *pkey)
 {
 	struct ib_pkey_cache *cache;
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	int ret = 0;
 
 	if (!rdma_is_port_valid(device, port_num))
@@ -956,7 +956,7 @@ int ib_find_cached_pkey(struct ib_device *device,
 			u16              *index)
 {
 	struct ib_pkey_cache *cache;
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	int i;
 	int ret = -ENOENT;
 	int partial_ix = -1;
@@ -997,7 +997,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
 			      u16              *index)
 {
 	struct ib_pkey_cache *cache;
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	int i;
 	int ret = -ENOENT;
 
@@ -1027,7 +1027,7 @@ int ib_get_cached_lmc(struct ib_device *device,
 		      u8                port_num,
 		      u8                *lmc)
 {
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	int ret = 0;
 
 	if (!rdma_is_port_valid(device, port_num))
diff --git a/sys/ofed/drivers/infiniband/core/ib_cm.c b/sys/ofed/drivers/infiniband/core/ib_cm.c
index 3ee17a847720..7ace287b1c88 100644
--- a/sys/ofed/drivers/infiniband/core/ib_cm.c
+++ b/sys/ofed/drivers/infiniband/core/ib_cm.c
@@ -4057,7 +4057,7 @@ static void cm_add_one(struct ib_device *ib_device)
 	struct ib_port_modify port_modify = {
 		.set_port_cap_mask = IB_PORT_CM_SUP
 	};
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	int ret;
 	int count = 0;
 	u8 i;
@@ -4150,7 +4150,7 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data)
 	struct ib_port_modify port_modify = {
 		.clr_port_cap_mask = IB_PORT_CM_SUP
 	};
-	unsigned long flags;
+	unsigned long flags __writeonly;
 	int i;
 
 	if (!cm_dev)