linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Arnd Bergmann <arnd@kernel.org>,
	QCA ath9k Development <ath9k-devel@qca.qualcomm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 08/11] ath9k: work around false-positive gcc warning
Date: Sat, 07 Nov 2020 13:18:10 +0200	[thread overview]
Message-ID: <87tuu1fma5.fsf@codeaurora.org> (raw)
In-Reply-To: <47b04bd1da38a2356546284eb3576156899965de.camel@sipsolutions.net> (Johannes Berg's message of "Mon, 02 Nov 2020 18:59:49 +0100")

Johannes Berg <johannes@sipsolutions.net> writes:

> On Mon, 2020-11-02 at 18:26 +0200, Kalle Valo wrote:
>> Arnd Bergmann <arnd@kernel.org> writes:
>> 
>> > From: Arnd Bergmann <arnd@arndb.de>
>> > 
>> > gcc-10 shows a false-positive warning with CONFIG_KASAN:
>> > 
>> > drivers/net/wireless/ath/ath9k/dynack.c: In function 'ath_dynack_sample_tx_ts':
>> > include/linux/etherdevice.h:290:14: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=]
>> >   290 |  *(u32 *)dst = *(const u32 *)src;
>> >       |  ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
>> > 
>> > Until gcc is fixed, work around this by using memcpy() in place
>> > of ether_addr_copy(). Hopefully gcc-11 will not have this problem.
>> > 
>> > Link: https://godbolt.org/z/sab1MK
>> > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490
>> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> > ---
>> >  drivers/net/wireless/ath/ath9k/dynack.c | 6 ++++++
>> >  1 file changed, 6 insertions(+)
>> > 
>> > diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
>> > index fbeb4a739d32..e4eb96b26ca4 100644
>> > --- a/drivers/net/wireless/ath/ath9k/dynack.c
>> > +++ b/drivers/net/wireless/ath/ath9k/dynack.c
>> > @@ -247,8 +247,14 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
>> >  	ridx = ts->ts_rateindex;
>> >  
>> >  	da->st_rbf.ts[da->st_rbf.t_rb].tstamp = ts->ts_tstamp;
>> > +#if defined(CONFIG_KASAN) && (CONFIG_GCC_VERSION >= 100000) && (CONFIG_GCC_VERSION < 110000)
>> > +	/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490 */
>> > +	memcpy(da->st_rbf.addr[da->st_rbf.t_rb].h_dest, hdr->addr1, ETH_ALEN);
>> > +	memcpy(da->st_rbf.addr[da->st_rbf.t_rb].h_src, hdr->addr2, ETH_ALEN);
>> > +#else
>> >  	ether_addr_copy(da->st_rbf.addr[da->st_rbf.t_rb].h_dest, hdr->addr1);
>> >  	ether_addr_copy(da->st_rbf.addr[da->st_rbf.t_rb].h_src, hdr->addr2);
>> > +#endif
>> 
>> Isn't there a better way to handle this? I really would not want
>> checking for GCC versions become a common approach in drivers.
>> 
>> I even think that using memcpy() always is better than the ugly ifdef.
>
> If you put memcpy() always somebody will surely go and clean it up to
> use ether_addr_copy() soon ...

I can always add a comment and hope that the cleanup people read
comments :) I did that now in the pending branch:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=25cfc077bd7a798d1aa527ad2aa9932bb3284376

Does that look ok? I prefer that over the ifdef.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

  parent reply	other threads:[~2020-11-07 11:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201026213040.3889546-1-arnd@kernel.org>
2020-10-26 21:29 ` [PATCH net-next 02/11] net: hostap: fix function cast warning Arnd Bergmann
2020-11-07 11:37   ` Kalle Valo
2020-10-26 21:29 ` [PATCH net-next 06/11] rtlwifi: fix -Wpointer-sign warning Arnd Bergmann
2020-10-27  1:29   ` Pkshih
2020-10-26 21:29 ` [PATCH net-next 07/11] rtw88: remove extraneous 'const' qualifier Arnd Bergmann
2020-10-27  1:49   ` Nathan Chancellor
2020-10-26 21:29 ` [PATCH net-next 08/11] ath9k: work around false-positive gcc warning Arnd Bergmann
2020-11-02 16:26   ` Kalle Valo
2020-11-02 17:59     ` Johannes Berg
2020-11-02 22:29       ` Arnd Bergmann
2020-11-07 11:18       ` Kalle Valo [this message]
2020-11-07 11:36         ` Arnd Bergmann
2020-11-10 18:13   ` Kalle Valo
2020-10-26 21:29 ` [PATCH net-next 09/11] ath6kl: fix enum-conversion warning Arnd Bergmann
2020-10-27  6:15   ` Kalle Valo
2020-11-07  8:08   ` Kalle Valo

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=87tuu1fma5.fsf@codeaurora.org \
    --to=kvalo@codeaurora.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=ath9k-devel@qca.qualcomm.com \
    --cc=davem@davemloft.net \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).