* [PATCH] RDMA/hfi1: use a struct group to avoid warning
@ 2025-04-03 14:47 Arnd Bergmann
2025-04-07 18:27 ` Jason Gunthorpe
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2025-04-03 14:47 UTC (permalink / raw)
To: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
Cc: Arnd Bergmann, Steven Rostedt (Google), Thomas Hellström,
Jani Nikula, Christian König, Dr. David Alan Gilbert,
Maher Sanalla, 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>
---
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 cb630551cf1a..fca37eb167cc 100644
--- a/drivers/infiniband/hw/hfi1/hfi.h
+++ b/drivers/infiniband/hw/hfi1/hfi.h
@@ -883,8 +883,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 b39f63ce6dfc..0dea8d01e868 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -3870,8 +3870,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] 4+ messages in thread
* Re: [PATCH] RDMA/hfi1: use a struct group to avoid warning
2025-04-03 14:47 [PATCH] RDMA/hfi1: use a struct group to avoid warning Arnd Bergmann
@ 2025-04-07 18:27 ` Jason Gunthorpe
2025-04-08 12:40 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2025-04-07 18:27 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Dennis Dalessandro, Leon Romanovsky, Arnd Bergmann,
Steven Rostedt (Google), Thomas Hellström, Jani Nikula,
Christian König, Dr. David Alan Gilbert, Maher Sanalla,
linux-rdma, linux-kernel
On Thu, Apr 03, 2025 at 04:47:53PM +0200, Arnd Bergmann wrote:
> 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.
Er.. so do we really want to fix it or just ignore this on gcc-11? Or
is there really a compile bug here and it is mis-generating the code?
The unneeded struct group seems ugly to me?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/hfi1: use a struct group to avoid warning
2025-04-07 18:27 ` Jason Gunthorpe
@ 2025-04-08 12:40 ` Arnd Bergmann
2025-04-10 7:59 ` Leon Romanovsky
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2025-04-08 12:40 UTC (permalink / raw)
To: Jason Gunthorpe, Arnd Bergmann
Cc: Dennis Dalessandro, Leon Romanovsky, Steven Rostedt,
Thomas Hellström, Jani Nikula, Christian König, linux,
Maher Sanalla, linux-rdma, linux-kernel
On Mon, Apr 7, 2025, at 20:27, Jason Gunthorpe wrote:
> On Thu, Apr 03, 2025 at 04:47:53PM +0200, Arnd Bergmann wrote:
>> 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.
>
> Er.. so do we really want to fix it or just ignore this on gcc-11? Or
> is there really a compile bug here and it is mis-generating the code?
>
> The unneeded struct group seems ugly to me?
Having a clean build would be nice though. Do you think a patch
that just turns off the warning locally would be better?
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/hfi1: use a struct group to avoid warning
2025-04-08 12:40 ` Arnd Bergmann
@ 2025-04-10 7:59 ` Leon Romanovsky
0 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2025-04-10 7:59 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jason Gunthorpe, Arnd Bergmann, Dennis Dalessandro,
Steven Rostedt, Thomas Hellström, Jani Nikula,
Christian König, linux, Maher Sanalla, linux-rdma,
linux-kernel
On Tue, Apr 08, 2025 at 02:40:38PM +0200, Arnd Bergmann wrote:
> On Mon, Apr 7, 2025, at 20:27, Jason Gunthorpe wrote:
> > On Thu, Apr 03, 2025 at 04:47:53PM +0200, Arnd Bergmann wrote:
> >> 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.
> >
> > Er.. so do we really want to fix it or just ignore this on gcc-11? Or
> > is there really a compile bug here and it is mis-generating the code?
> >
> > The unneeded struct group seems ugly to me?
>
> Having a clean build would be nice though. Do you think a patch
> that just turns off the warning locally would be better?
I don't think so, as you will need to disable warning for specific
compiler, which won't be nice.
My preference is to have a fix.
Thanks
>
> Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-10 7:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-03 14:47 [PATCH] RDMA/hfi1: use a struct group to avoid warning Arnd Bergmann
2025-04-07 18:27 ` Jason Gunthorpe
2025-04-08 12:40 ` Arnd Bergmann
2025-04-10 7:59 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).