From patchwork Thu Apr 3 14:47:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 14036983 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2955124EF9A; Thu, 3 Apr 2025 14:48:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743691687; cv=none; b=F1JA9wbFi7B5t654mURKtmHvLFii1B1wN+p/UD7VuiBaS7y36dYiX7/T7cSJgl9IPjw4TiDYKF5RmarbKWMDY/AmrIbqeavYSMZ/muWb2CFDirbjYhwQrYM3YGzaNmi+f/hbYIu7/CYKNbr4zj5ELyn1N7csE6yg6ufphE8RuBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743691687; c=relaxed/simple; bh=RrOTQcuANEq2RAIgj9UZ3synNzyYf0fgpXeVeZABxAo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=nADAjyXlugAMk0P+dPskWd/g++glVqZUsvdvI4cv0oMA9TDzVUd82p/vVlyOWSniRJmmviuyHlhV4FVMtmYKUy6FiA7U2DwaroDqVZPVpBa4beLcXEsvS3AM2AHlrez0pgydUfs/zz2SLS+uZLxl+aVBfUUuHTi7OJHVSo7VGwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q7Liz9Cc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q7Liz9Cc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 616A3C4CEE7; Thu, 3 Apr 2025 14:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743691686; bh=RrOTQcuANEq2RAIgj9UZ3synNzyYf0fgpXeVeZABxAo=; h=From:To:Cc:Subject:Date:From; b=Q7Liz9CcnNg0gAkVAdZyi3RFCL4HagRv98rowwXJS9mRJRN74/Mi2z2qTb2RnFzGm GT481oqIW/8dLNPTWS0QlYdnOIupI6Z+b4lyVLQC+AHaMkoZeEccO3ebdWiPF/uFIe E2ouYwM1Iw1asTI3Kuv41gwH1bUJ2HZQnfbg7GqR32oGfhD1QYloC8bSk6wqdP8NHn I2RnqX7Zvjd6kHHk+74EIaS+rBkYlFVyZsOAkjIqSxu7BuYXEbpQTDWjKaOG9/a5Ip XB5KqmONckpRXOikeNGMLtfJdBSAIfe2o6LBRhRu2ChOmf9c5NzsbTCxqftcfupAB6 Thmm7N1UndLqA== From: Arnd Bergmann To: Dennis Dalessandro , Jason Gunthorpe , Leon Romanovsky Cc: Arnd Bergmann , "Steven Rostedt (Google)" , =?utf-8?q?Thomas_Hellstr?= =?utf-8?q?=C3=B6m?= , Jani Nikula , =?utf-8?q?Christian_K=C3=B6nig?= , "Dr. David Alan Gilbert" , Maher Sanalla , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] RDMA/hfi1: use a struct group to avoid warning Date: Thu, 3 Apr 2025 16:47:53 +0200 Message-Id: <20250403144801.3779379-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann 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 --- 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);