public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] [RESEND] RDMA/hfi1: use a struct group to avoid warning
@ 2026-03-20 15:12 Arnd Bergmann
  2026-03-20 15:12 ` [PATCH 2/3] RDMA/hfi1, rdmavt: open-code rvt_set_ibdev_name() Arnd Bergmann
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Arnd Bergmann @ 2026-03-20 15:12 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
  Cc: Arnd Bergmann, Kees Cook, Ingo Molnar, Thomas Gleixner,
	linux-rdma, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

On gcc-11 and earlier, the driver sometimes produces a warning
for memset:

In file included from include/linux/string.h:392,
                 from drivers/infiniband/hw/hfi1/mad.c:6:
In function 'fortify_memset_chk',
    inlined from '__subn_get_opa_hfi1_cong_log' at drivers/infiniband/hw/hfi1/mad.c:3873:2,
    inlined from 'subn_get_opa_sma' at drivers/infiniband/hw/hfi1/mad.c:4114:9:
include/linux/fortify-string.h:480:4: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror]
    __write_overflow_field(p_size_field, size);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This seems to be a false positive, and I found no nice way to rewrite
the code to avoid the warning, but adding a a struct group works.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
resending as the patch did not get picked up last year
https://lore.kernel.org/all/20250410075928.GN199604@unreal/
---
 drivers/infiniband/hw/hfi1/hfi.h | 6 ++++--
 drivers/infiniband/hw/hfi1/mad.c | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
index 5a0310f758dc..ae17cea4e8c9 100644
--- a/drivers/infiniband/hw/hfi1/hfi.h
+++ b/drivers/infiniband/hw/hfi1/hfi.h
@@ -878,8 +878,10 @@ struct hfi1_pportdata {
 	 * cc_log_lock protects all congestion log related data
 	 */
 	spinlock_t cc_log_lock ____cacheline_aligned_in_smp;
-	u8 threshold_cong_event_map[OPA_MAX_SLS / 8];
-	u16 threshold_event_counter;
+	struct_group (zero_event_map,
+		u8 threshold_cong_event_map[OPA_MAX_SLS / 8];
+		u16 threshold_event_counter;
+	);
 	struct opa_hfi1_cong_log_event_internal cc_events[OPA_CONG_LOG_ELEMS];
 	int cc_log_idx; /* index for logging events */
 	int cc_mad_idx; /* index for reporting events */
diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index 585f1d99b91b..9154638e9ce2 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -3869,8 +3869,8 @@ static int __subn_get_opa_hfi1_cong_log(struct opa_smp *smp, u32 am,
 	 * Reset threshold_cong_event_map, and threshold_event_counter
 	 * to 0 when log is read.
 	 */
-	memset(ppd->threshold_cong_event_map, 0x0,
-	       sizeof(ppd->threshold_cong_event_map));
+	memset(&ppd->zero_event_map, 0x0,
+	       sizeof(ppd->zero_event_map));
 	ppd->threshold_event_counter = 0;
 
 	spin_unlock_irq(&ppd->cc_log_lock);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-03-24  7:54 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 15:12 [PATCH 1/3] [RESEND] RDMA/hfi1: use a struct group to avoid warning Arnd Bergmann
2026-03-20 15:12 ` [PATCH 2/3] RDMA/hfi1, rdmavt: open-code rvt_set_ibdev_name() Arnd Bergmann
2026-03-20 15:53   ` Arnd Bergmann
2026-03-23  8:08     ` Leon Romanovsky
2026-03-23  8:48       ` Arnd Bergmann
2026-03-23 11:01         ` Leon Romanovsky
2026-03-23 21:47           ` Dennis Dalessandro
2026-03-24  7:27             ` Arnd Bergmann
2026-03-24  7:51               ` Leon Romanovsky
2026-03-24  7:53             ` Leon Romanovsky
2026-03-23 21:54         ` Dennis Dalessandro
2026-03-22 18:29   ` kernel test robot
2026-03-22 20:12   ` kernel test robot
2026-03-24  1:29   ` kernel test robot
2026-03-20 15:12 ` [PATCH 3/3] RDMA/hfi1: reduce namespace pollution Arnd Bergmann
2026-03-20 18:01 ` [PATCH 1/3] [RESEND] RDMA/hfi1: use a struct group to avoid warning Kees Cook
2026-03-20 21:49 ` yanjun.zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox