Message ID | 20230214132025.1532147-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2969602wrn; Tue, 14 Feb 2023 05:25:02 -0800 (PST) X-Google-Smtp-Source: AK7set9k/gJZJZ9ivz6f+OW42ijzIUI1UuToggfW3i0btiFCQ+WyKLF5sTOCxI1U0PNH+sCrptJK X-Received: by 2002:a17:906:edaf:b0:879:9c05:f5e8 with SMTP id sa15-20020a170906edaf00b008799c05f5e8mr2898541ejb.62.1676381102814; Tue, 14 Feb 2023 05:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676381102; cv=none; d=google.com; s=arc-20160816; b=VUbj+ubNNGJn9vwU1b8p1EcI1o0dLyXjN0deehAAWw1SQjTGJtNPI8QhRfkffjDGjw FRBhGw3/4nzIMLdgXApfRgs/G82LSs92sdvR9zfHHvLLYw34QElGClStJYM24CNAnzrK HqkqEkD0j7uX8PkC2d27Pci7o2lQMCfAi0mgSJA/mBGFd7UclbGcpZVrctXDcxBAczvw wjXACWxpRnUucPgNfyLxz6F+aLX6VwQlOEClBIRdAHzWCG4ilnZUfrSVgHTkxgIkpyyM Lzr6XZnNrlRSZcOVWXg+uCDfwFj+Hjci/UFD/ks419tE4mO9XJICpYmYOb1piWmWdbEk lQLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hdym0EkYY75A6C+TST5/l3AvKUtHdKduNQTPVoeoq6k=; b=s41GgezB7dahe4q4tk5QROAu6coY3twxQDY57nTM7xI06hd9ScnFZdIXjrjU8VZ5EQ F/V3Fu6D21pZTu4vVLDyuYkLyeqhzBIiMp/FBmSu2qB4ypumo1b9+fkSK3tgZkOTXsPb vUijUKhfqnMwBcBqTd35REWdqTFF62agtqflq8B6ObaCxRz4eqWbhR2eoqdHFqMT7muC BVJDL4l+Lepu+WKgj6r++TebnpDadBrZWs2cvj2/9HE+OYnfCriWMRF9gzAEG86bSnW/ G4FpPpcCT8mSolN1UbPly+5a1uhGFILpZmITNjNxLYGulG1gG/HdBcaJfDsW0pzL2I5T HHWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="i07/HRMl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fr31-20020a170906891f00b0088519b9207bsi17225025ejc.638.2023.02.14.05.24.39; Tue, 14 Feb 2023 05:25:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="i07/HRMl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232489AbjBNNUv (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 14 Feb 2023 08:20:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbjBNNUs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Feb 2023 08:20:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77FEE2658D; Tue, 14 Feb 2023 05:20:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2BEB9B81D5D; Tue, 14 Feb 2023 13:20:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E3C2C433D2; Tue, 14 Feb 2023 13:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676380828; bh=QSNzfjDyD1D0CyaWZ5xpZ1cspur47SIVwpCpx1kP5uA=; h=From:To:Cc:Subject:Date:From; b=i07/HRMlK5b+wFq9NbkvN7kofxmDDRuxlAKgYpYBUfJQQ/J+YJQLBtuNwEPIx1pMF ZgLtxJ7dKdwMQ/HJy1agHC80+JbhGbRlUaju2Gidn+u1tIu3sFUzXVjPPobsPyvdst RrCL567tF8na20h0ERXDah1QCdb7aC2dZ8Vd7JR8hJs8/2gVijoDq7eXHc54cRuMqV JzGCLRQqT10PbUkKvGIjJCpqvZgibV2tPzidZ4HEoHsZkYJt6+IjcMWwfi9A6NRKBD 2I1JpiK6ASQO0AKAckz2OFB8XhQZjIUNgVlqeDuZVm/OwOcylWZZ2m96J9a2tlxlBR bNHSK7fEEcsrA== From: Arnd Bergmann <arnd@kernel.org> To: Johannes Berg <johannes@sipsolutions.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de>, Felix Fietkau <nbd@nbd.name>, Alexander Wetzel <alexander@wetzel-home.de>, =?utf-8?q?Toke_H=C3=B8iland-J?= =?utf-8?q?=C3=B8rgensen?= <toke@toke.dk>, Andrei Otcheretianski <andrei.otcheretianski@intel.com>, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] wifi: mac80211: avoid u32_encode_bits() warning Date: Tue, 14 Feb 2023 14:20:21 +0100 Message-Id: <20230214132025.1532147-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757812991370003354?= X-GMAIL-MSGID: =?utf-8?q?1757812991370003354?= |
Series |
wifi: mac80211: avoid u32_encode_bits() warning
|
|
Commit Message
Arnd Bergmann
Feb. 14, 2023, 1:20 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> gcc-9 triggers a false-postive warning in ieee80211_mlo_multicast_tx() for u32_encode_bits(ffs(links) - 1, ...), since ffs() can return zero on an empty bitmask, and the negative argument to u32_encode_bits() is then out of range: In file included from include/linux/ieee80211.h:21, from include/net/cfg80211.h:23, from net/mac80211/tx.c:23: In function 'u32_encode_bits', inlined from 'ieee80211_mlo_multicast_tx' at net/mac80211/tx.c:4437:17, inlined from 'ieee80211_subif_start_xmit' at net/mac80211/tx.c:4485:3: include/linux/bitfield.h:177:3: error: call to '__field_overflow' declared with attribute error: value doesn't fit into mask 177 | __field_overflow(); \ | ^~~~~~~~~~~~~~~~~~ include/linux/bitfield.h:197:2: note: in expansion of macro '____MAKE_OP' 197 | ____MAKE_OP(u##size,u##size,,) | ^~~~~~~~~~~ include/linux/bitfield.h:200:1: note: in expansion of macro '__MAKE_OP' 200 | __MAKE_OP(32) | ^~~~~~~~~ Newer compiler versions do not cause problems with the zero argument because they do not consider this a __builtin_constant_p(). It's also harmless since the hweight16() check already guarantees that this cannot be 0. Replace the ffs() with an equivalent find_first_bit() check that matches the later for_each_set_bit() style and avoids the warning. Fixes: 963d0e8d08d9 ("wifi: mac80211: optionally implement MLO multicast TX") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- net/mac80211/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
From: Arnd Bergmann <arnd@kernel.org> Date: Tue, 14 Feb 2023 14:20:21 +0100 > From: Arnd Bergmann <arnd@arndb.de> > > gcc-9 triggers a false-postive warning in ieee80211_mlo_multicast_tx() > for u32_encode_bits(ffs(links) - 1, ...), since ffs() can return zero > on an empty bitmask, and the negative argument to u32_encode_bits() > is then out of range: > > In file included from include/linux/ieee80211.h:21, > from include/net/cfg80211.h:23, > from net/mac80211/tx.c:23: > In function 'u32_encode_bits', > inlined from 'ieee80211_mlo_multicast_tx' at net/mac80211/tx.c:4437:17, > inlined from 'ieee80211_subif_start_xmit' at net/mac80211/tx.c:4485:3: > include/linux/bitfield.h:177:3: error: call to '__field_overflow' declared with attribute error: value doesn't fit into mask > 177 | __field_overflow(); \ > | ^~~~~~~~~~~~~~~~~~ > include/linux/bitfield.h:197:2: note: in expansion of macro '____MAKE_OP' > 197 | ____MAKE_OP(u##size,u##size,,) > | ^~~~~~~~~~~ > include/linux/bitfield.h:200:1: note: in expansion of macro '__MAKE_OP' > 200 | __MAKE_OP(32) > | ^~~~~~~~~ > > Newer compiler versions do not cause problems with the zero argument > because they do not consider this a __builtin_constant_p(). > It's also harmless since the hweight16() check already guarantees > that this cannot be 0. > > Replace the ffs() with an equivalent find_first_bit() check that > matches the later for_each_set_bit() style and avoids the warning. > > Fixes: 963d0e8d08d9 ("wifi: mac80211: optionally implement MLO multicast TX") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > net/mac80211/tx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c > index defe97a31724..118648af979c 100644 > --- a/net/mac80211/tx.c > +++ b/net/mac80211/tx.c > @@ -4434,7 +4434,7 @@ static void ieee80211_mlo_multicast_tx(struct net_device *dev, > u32 ctrl_flags = IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX; > > if (hweight16(links) == 1) { > - ctrl_flags |= u32_encode_bits(ffs(links) - 1, > + ctrl_flags |= u32_encode_bits(find_first_bit(&links, 16) - 1, Uff, IIRC find_first_bit() matches __ffs() calling convention, not ffs() one. They're off-by-one from each other, which means you need to drop this `- 1`. As this branch happens only when hweight is 1 => @links has a bit set, it's safe to just use __ffs() here directly, but up to you. find_first_bit() is fine, too, since it will be optimized out to __ffs() at the end in this case. > IEEE80211_TX_CTRL_MLO_LINK); > > __ieee80211_subif_start_xmit(skb, sdata->dev, 0, ctrl_flags, Thanks, Olek
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index defe97a31724..118648af979c 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -4434,7 +4434,7 @@ static void ieee80211_mlo_multicast_tx(struct net_device *dev, u32 ctrl_flags = IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX; if (hweight16(links) == 1) { - ctrl_flags |= u32_encode_bits(ffs(links) - 1, + ctrl_flags |= u32_encode_bits(find_first_bit(&links, 16) - 1, IEEE80211_TX_CTRL_MLO_LINK); __ieee80211_subif_start_xmit(skb, sdata->dev, 0, ctrl_flags,