From: Jiri Slaby <jirislaby@kernel.org>
To: Shiji Yang <yangshiji66@outlook.com>, linux-wireless@vger.kernel.org
Cc: "Kalle Valo" <kvalo@kernel.org>,
"Nick Kossifidis" <mickflemm@gmail.com>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Toke Høiland-Jørgensen" <toke@toke.dk>,
"Robert Marko" <robimarko@gmail.com>,
"Christian Lamparter" <chunkeey@gmail.com>,
"Christian Marangi" <ansuelsmth@gmail.com>,
"Shiji Yang" <yangshiji66@qq.com>
Subject: Re: [PATCH] wifi: ath: add struct_group for struct ath_cycle_counters
Date: Fri, 2 Jun 2023 06:58:31 +0200 [thread overview]
Message-ID: <d68c4b38-88e1-02ef-5779-08b93fd0d47b@kernel.org> (raw)
In-Reply-To: <TYAP286MB0315EC437BF53C8DB2B5D022BC4EA@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM>
On 02. 06. 23, 6:36, Shiji Yang wrote:
> From: Shiji Yang <yangshiji66@qq.com>
>
> Add a struct_group to around all members in struct ath_cycle_counters.
> It can help the compiler detect the intended bounds of the memcpy() and
> memset().
>
> This patch fixes the following build warning:
>
> In function 'fortify_memset_chk',
> inlined from 'ath9k_ps_wakeup' at drivers/net/wireless/ath/ath9k/main.c:140:3:
> ./include/linux/fortify-string.h:314:25: error: call to '__write_overflow_field' declared with attribute warning:
> detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
> 314 | __write_overflow_field(p_size_field, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
Hi,
what compiler/version is this with?
> Signed-off-by: Shiji Yang <yangshiji66@qq.com>
> ---
> More discussion on: https://github.com/openwrt/openwrt/pull/12764
No "__write_overflow_field" there. Is this the right link?
> ---
> drivers/net/wireless/ath/ath.h | 10 ++++++----
> drivers/net/wireless/ath/ath5k/ani.c | 2 +-
> drivers/net/wireless/ath/ath5k/base.c | 4 ++--
> drivers/net/wireless/ath/ath5k/mac80211-ops.c | 2 +-
> drivers/net/wireless/ath/ath9k/link.c | 2 +-
> drivers/net/wireless/ath/ath9k/main.c | 4 ++--
> drivers/net/wireless/ath/hw.c | 2 +-
> 7 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
> index f02a308a9..4b42e401a 100644
> --- a/drivers/net/wireless/ath/ath.h
> +++ b/drivers/net/wireless/ath/ath.h
> @@ -43,10 +43,12 @@ struct ath_ani {
> };
>
> struct ath_cycle_counters {
> - u32 cycles;
> - u32 rx_busy;
> - u32 rx_frame;
> - u32 tx_frame;
> + struct_group(cnts,
> + u32 cycles;
> + u32 rx_busy;
> + u32 rx_frame;
> + u32 tx_frame;
> + );
This is horrid.
> };
>
> enum ath_device_state {
> diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c
> index 850c608b4..fa95f0f0f 100644
> --- a/drivers/net/wireless/ath/ath5k/ani.c
> +++ b/drivers/net/wireless/ath/ath5k/ani.c
> @@ -379,7 +379,7 @@ ath5k_hw_ani_get_listen_time(struct ath5k_hw *ah, struct ath5k_ani_state *as)
> spin_lock_bh(&common->cc_lock);
>
> ath_hw_cycle_counters_update(common);
> - memcpy(&as->last_cc, &common->cc_ani, sizeof(as->last_cc));
> + memcpy(&as->last_cc.cnts, &common->cc_ani.cnts, sizeof(as->last_cc.cnts));
So is this.
Care to elaborate why this is needed at all, provided we copy/zero a
whole structure? And describe it in the commit log, not in random
external sources.
thanks,
--
js
suse labs
next prev parent reply other threads:[~2023-06-02 4:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 4:36 [PATCH] wifi: ath: add struct_group for struct ath_cycle_counters Shiji Yang
2023-06-02 4:58 ` Jiri Slaby [this message]
2023-06-02 5:19 ` Kalle Valo
2023-06-04 1:46 ` Shiji Yang
2023-06-04 1:40 ` Shiji Yang
2023-06-04 1:48 ` Shiji Yang
2023-06-04 11:11 ` Christian Lamparter
2023-06-05 6:00 ` Jiri Slaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d68c4b38-88e1-02ef-5779-08b93fd0d47b@kernel.org \
--to=jirislaby@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=chunkeey@gmail.com \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mickflemm@gmail.com \
--cc=robimarko@gmail.com \
--cc=toke@toke.dk \
--cc=yangshiji66@outlook.com \
--cc=yangshiji66@qq.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox