Message ID | 20221215165553.1950307-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp481810wrn; Thu, 15 Dec 2022 09:02:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5qMltrHct6kqUu8ikY89UGQ3VrZUKEdocL0Y3UddqqVYJy2tlAcBZuA3xRvMtz8tt29AMQ X-Received: by 2002:a17:906:6d52:b0:7c1:5b5e:4d78 with SMTP id a18-20020a1709066d5200b007c15b5e4d78mr17967428ejt.51.1671123761042; Thu, 15 Dec 2022 09:02:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671123761; cv=none; d=google.com; s=arc-20160816; b=zMr73GmfX/etsYsEZeCxLtU0H9tkUDhiWRB1V59yssZ/TvOVD342WeSaT78ZG6/16o 84hkjva+hlawkcrHN2PfigShwL7V4kbqpa/XZHJPWkxN8qR6zI2I4ZGFF6Fe5jVNYiPU +DzjvzmbN976nRd35Y+KqX950QfRNmIy8Rt6sqfCkCnBiebXUKCscJhXdhKp0NyXuuja cUdxFbMrLSMzTlhZzTTdG7hvdhOg3a54EDbo6KNrtYcXuqcI+56P16KTBsbjCRS+oAwm NbY8NP051EgV9ohDFav/WuBKA8npnZW74cz4vHQI7efEbzRCxmtYrKfRQZhtwk8whCS7 +29Q== 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=rwfwawr+0yBhMM2634VZPw1k6oy9S5zm2ZJOKaEKpuU=; b=pTxRuPcHIS8PJknpR4pv9DWlaR5+4pg6qv5WSbeKzoVsZFyKpU25RY5phCBPsz48yW ndG0SkJGTF/wanvbi4PW0bLgaxPiz/kpBwO7/GgMHg+ouJhMoputxmWtWqAwBdq5u5Oc 7LFALkOQ7RNpNq1E/MCflQk3wA7HOWWsjGTyFi8Yr6nucWMG5UD8p58mYXWu3+GyK9wd +P3RrYmgHPZbG0b2a8tMTOKi1y2sgEAo1o1F3pK1fZtFv42grnjtd6fqJrfcQBshEAy7 yIOkWcVPBE8zOVJBHkba2EAmb2fZTmI1yEhDCsixg7ceNr92Us7oDbgbwtBbSCvBEB+o JGIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LXoIjw5r; 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 gw9-20020a170906f14900b007c0ea5a7ca4si11904830ejb.858.2022.12.15.09.02.17; Thu, 15 Dec 2022 09:02:41 -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=LXoIjw5r; 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 S230398AbiLOQ4M (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Thu, 15 Dec 2022 11:56:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbiLOQ4C (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 15 Dec 2022 11:56:02 -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 97CE6E088; Thu, 15 Dec 2022 08:56:01 -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 4D5C1B81C03; Thu, 15 Dec 2022 16:56:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69E0BC433EF; Thu, 15 Dec 2022 16:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671123359; bh=tVhkH/FcY9gESy+V3xeK947kCGObkEYr+sAE3pHakis=; h=From:To:Cc:Subject:Date:From; b=LXoIjw5ra7kHRbvYTXP6NigITE4JtnJBxLDqJvA4kbg7jKh7PCVIvaWKZXXlEpAA+ Ha1v4BRa9Gnf6/ruDAN2j/Y/EXBz65z2x77sh3ozb/BZoeP263lObyomW2MW75Rqcr vd0uZ6dtjPt3xtmRkG5sSdNQ3v+0FWP8UtQ9YCYnXzb+5QzogKJOfxyaLbZ1thQayo lWfWdEIsOCy8HMjoI+z68/JlRbUVoxxgC2y8rFRfUZ7ofb3ujdTtH90M0KxjoJ8rXb wqQ1Qj5F2Uni/kMo6MwlxGch9dneycHhG96i0Qglyy8DH+ufc+U6+CH3Vqcsz2/qUh 2Yumvup4npcjw== From: Arnd Bergmann <arnd@kernel.org> To: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>, Kalle Valo <kvalo@kernel.org>, Pavel Skripkin <paskripkin@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ath9k: use proper statements in conditionals Date: Thu, 15 Dec 2022 17:55:42 +0100 Message-Id: <20221215165553.1950307-1-arnd@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1752300268733431893?= X-GMAIL-MSGID: =?utf-8?q?1752300268733431893?= |
Series |
ath9k: use proper statements in conditionals
|
|
Commit Message
Arnd Bergmann
Dec. 15, 2022, 4:55 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> A previous cleanup patch accidentally broke some conditional expressions by replacing the safe "do {} while (0)" constructs with empty macros. gcc points this out when extra warnings are enabled: drivers/net/wireless/ath/ath9k/hif_usb.c: In function 'ath9k_skb_queue_complete': drivers/net/wireless/ath/ath9k/hif_usb.c:251:57: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body] 251 | TX_STAT_INC(hif_dev, skb_failed); Make both sets of macros proper expressions again. Fixes: d7fc76039b74 ("ath9k: htc: clean up statistics macros") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/wireless/ath/ath9k/htc.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Comments
Arnd Bergmann <arnd@kernel.org> writes: > From: Arnd Bergmann <arnd@arndb.de> > > A previous cleanup patch accidentally broke some conditional > expressions by replacing the safe "do {} while (0)" constructs > with empty macros. gcc points this out when extra warnings > are enabled: > > drivers/net/wireless/ath/ath9k/hif_usb.c: In function 'ath9k_skb_queue_complete': > drivers/net/wireless/ath/ath9k/hif_usb.c:251:57: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body] > 251 | TX_STAT_INC(hif_dev, skb_failed); > > Make both sets of macros proper expressions again. > > Fixes: d7fc76039b74 ("ath9k: htc: clean up statistics macros") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/net/wireless/ath/ath9k/htc.h | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h > index 30f0765fb9fd..237f4ec2cffd 100644 > --- a/drivers/net/wireless/ath/ath9k/htc.h > +++ b/drivers/net/wireless/ath/ath9k/htc.h > @@ -327,9 +327,9 @@ static inline struct ath9k_htc_tx_ctl *HTC_SKB_CB(struct sk_buff *skb) > } > > #ifdef CONFIG_ATH9K_HTC_DEBUGFS > -#define __STAT_SAFE(hif_dev, expr) ((hif_dev)->htc_handle->drv_priv ? (expr) : 0) > -#define CAB_STAT_INC(priv) ((priv)->debug.tx_stats.cab_queued++) > -#define TX_QSTAT_INC(priv, q) ((priv)->debug.tx_stats.queue_stats[q]++) > +#define __STAT_SAFE(hif_dev, expr) do { ((hif_dev)->htc_handle->drv_priv ? (expr) : 0); } while (0) > +#define CAB_STAT_INC(priv) do { ((priv)->debug.tx_stats.cab_queued++); } while (0) > +#define TX_QSTAT_INC(priv, q) do { ((priv)->debug.tx_stats.queue_stats[q]++); } while (0) Hmm, is it really necessary to wrap these in do/while constructs? AFAICT they're all simple statements already? -Toke
On Thu, Dec 15, 2022, at 18:16, Toke Høiland-Jørgensen wrote: >> index 30f0765fb9fd..237f4ec2cffd 100644 >> --- a/drivers/net/wireless/ath/ath9k/htc.h >> +++ b/drivers/net/wireless/ath/ath9k/htc.h >> @@ -327,9 +327,9 @@ static inline struct ath9k_htc_tx_ctl *HTC_SKB_CB(struct sk_buff *skb) >> } >> >> #ifdef CONFIG_ATH9K_HTC_DEBUGFS >> -#define __STAT_SAFE(hif_dev, expr) ((hif_dev)->htc_handle->drv_priv ? (expr) : 0) >> -#define CAB_STAT_INC(priv) ((priv)->debug.tx_stats.cab_queued++) >> -#define TX_QSTAT_INC(priv, q) ((priv)->debug.tx_stats.queue_stats[q]++) >> +#define __STAT_SAFE(hif_dev, expr) do { ((hif_dev)->htc_handle->drv_priv ? (expr) : 0); } while (0) >> +#define CAB_STAT_INC(priv) do { ((priv)->debug.tx_stats.cab_queued++); } while (0) >> +#define TX_QSTAT_INC(priv, q) do { ((priv)->debug.tx_stats.queue_stats[q]++); } while (0) > > Hmm, is it really necessary to wrap these in do/while constructs? AFAICT > they're all simple statements already? It's generally safer to do the same thing on both side of the #ifdef. The "do { } while (0)" is an empty statement that is needed to fix the bug on the #else side. The expressions you have on the #ifdef side can be used as values, and wrapping them in do{}while(0) turns them into statements (without a value) as well, so fewer things can go wrong when you only test one side. I suppose the best solution would be to just use inline functions for all of them and get rid of the macros. Arnd
"Arnd Bergmann" <arnd@arndb.de> writes: > On Thu, Dec 15, 2022, at 18:16, Toke Høiland-Jørgensen wrote: >>> index 30f0765fb9fd..237f4ec2cffd 100644 >>> --- a/drivers/net/wireless/ath/ath9k/htc.h >>> +++ b/drivers/net/wireless/ath/ath9k/htc.h >>> @@ -327,9 +327,9 @@ static inline struct ath9k_htc_tx_ctl *HTC_SKB_CB(struct sk_buff *skb) >>> } >>> >>> #ifdef CONFIG_ATH9K_HTC_DEBUGFS >>> -#define __STAT_SAFE(hif_dev, expr) ((hif_dev)->htc_handle->drv_priv ? (expr) : 0) >>> -#define CAB_STAT_INC(priv) ((priv)->debug.tx_stats.cab_queued++) >>> -#define TX_QSTAT_INC(priv, q) ((priv)->debug.tx_stats.queue_stats[q]++) >>> +#define __STAT_SAFE(hif_dev, expr) do { ((hif_dev)->htc_handle->drv_priv ? (expr) : 0); } while (0) >>> +#define CAB_STAT_INC(priv) do { ((priv)->debug.tx_stats.cab_queued++); } while (0) >>> +#define TX_QSTAT_INC(priv, q) do { ((priv)->debug.tx_stats.queue_stats[q]++); } while (0) >> >> Hmm, is it really necessary to wrap these in do/while constructs? AFAICT >> they're all simple statements already? > > It's generally safer to do the same thing on both side of the #ifdef. > > The "do { } while (0)" is an empty statement that is needed to fix > the bug on the #else side. The expressions you have on the #ifdef > side can be used as values, and wrapping them in do{}while(0) > turns them into statements (without a value) as well, so fewer > things can go wrong when you only test one side. Alright, makes sense; thanks for explaining! > I suppose the best solution would be to just use inline functions > for all of them and get rid of the macros. Let's merge this patch to fix the bug, and if someone wants to follow up with a conversion to inline functions, that would be awesome, of course :) -Toke
Arnd Bergmann <arnd@kernel.org> writes: > From: Arnd Bergmann <arnd@arndb.de> > > A previous cleanup patch accidentally broke some conditional > expressions by replacing the safe "do {} while (0)" constructs > with empty macros. gcc points this out when extra warnings > are enabled: > > drivers/net/wireless/ath/ath9k/hif_usb.c: In function 'ath9k_skb_queue_complete': > drivers/net/wireless/ath/ath9k/hif_usb.c:251:57: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body] > 251 | TX_STAT_INC(hif_dev, skb_failed); > > Make both sets of macros proper expressions again. > > Fixes: d7fc76039b74 ("ath9k: htc: clean up statistics macros") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Toke Høiland-Jørgensen <toke@toke.dk> writes: > Arnd Bergmann <arnd@kernel.org> writes: > >> From: Arnd Bergmann <arnd@arndb.de> >> >> A previous cleanup patch accidentally broke some conditional >> expressions by replacing the safe "do {} while (0)" constructs >> with empty macros. gcc points this out when extra warnings >> are enabled: >> >> drivers/net/wireless/ath/ath9k/hif_usb.c: In function 'ath9k_skb_queue_complete': >> drivers/net/wireless/ath/ath9k/hif_usb.c:251:57: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body] >> 251 | TX_STAT_INC(hif_dev, skb_failed); >> >> Make both sets of macros proper expressions again. >> >> Fixes: d7fc76039b74 ("ath9k: htc: clean up statistics macros") >> Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > Acked-by: Toke Høiland-Jørgensen <toke@toke.dk> I'll queue this to v6.2.
Kalle Valo <kvalo@kernel.org> writes: > Toke Høiland-Jørgensen <toke@toke.dk> writes: > >> Arnd Bergmann <arnd@kernel.org> writes: >> >>> From: Arnd Bergmann <arnd@arndb.de> >>> >>> A previous cleanup patch accidentally broke some conditional >>> expressions by replacing the safe "do {} while (0)" constructs >>> with empty macros. gcc points this out when extra warnings >>> are enabled: >>> >>> drivers/net/wireless/ath/ath9k/hif_usb.c: In function 'ath9k_skb_queue_complete': >>> drivers/net/wireless/ath/ath9k/hif_usb.c:251:57: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body] >>> 251 | TX_STAT_INC(hif_dev, skb_failed); >>> >>> Make both sets of macros proper expressions again. >>> >>> Fixes: d7fc76039b74 ("ath9k: htc: clean up statistics macros") >>> Signed-off-by: Arnd Bergmann <arnd@arndb.de> >> >> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk> > > I'll queue this to v6.2. Sounds good, thanks! -Toke
Arnd Bergmann <arnd@kernel.org> wrote: > From: Arnd Bergmann <arnd@arndb.de> > > A previous cleanup patch accidentally broke some conditional > expressions by replacing the safe "do {} while (0)" constructs > with empty macros. gcc points this out when extra warnings > are enabled: > > drivers/net/wireless/ath/ath9k/hif_usb.c: In function 'ath9k_skb_queue_complete': > drivers/net/wireless/ath/ath9k/hif_usb.c:251:57: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body] > 251 | TX_STAT_INC(hif_dev, skb_failed); > > Make both sets of macros proper expressions again. > > Fixes: d7fc76039b74 ("ath9k: htc: clean up statistics macros") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > Acked-by: Toke Høiland-Jørgensen <toke@toke.dk> Patch applied to wireless.git, thanks. b7dc753fe33a wifi: ath9k: use proper statements in conditionals
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h index 30f0765fb9fd..237f4ec2cffd 100644 --- a/drivers/net/wireless/ath/ath9k/htc.h +++ b/drivers/net/wireless/ath/ath9k/htc.h @@ -327,9 +327,9 @@ static inline struct ath9k_htc_tx_ctl *HTC_SKB_CB(struct sk_buff *skb) } #ifdef CONFIG_ATH9K_HTC_DEBUGFS -#define __STAT_SAFE(hif_dev, expr) ((hif_dev)->htc_handle->drv_priv ? (expr) : 0) -#define CAB_STAT_INC(priv) ((priv)->debug.tx_stats.cab_queued++) -#define TX_QSTAT_INC(priv, q) ((priv)->debug.tx_stats.queue_stats[q]++) +#define __STAT_SAFE(hif_dev, expr) do { ((hif_dev)->htc_handle->drv_priv ? (expr) : 0); } while (0) +#define CAB_STAT_INC(priv) do { ((priv)->debug.tx_stats.cab_queued++); } while (0) +#define TX_QSTAT_INC(priv, q) do { ((priv)->debug.tx_stats.queue_stats[q]++); } while (0) #define TX_STAT_INC(hif_dev, c) \ __STAT_SAFE((hif_dev), (hif_dev)->htc_handle->drv_priv->debug.tx_stats.c++) @@ -378,10 +378,10 @@ void ath9k_htc_get_et_stats(struct ieee80211_hw *hw, struct ethtool_stats *stats, u64 *data); #else -#define TX_STAT_INC(hif_dev, c) -#define TX_STAT_ADD(hif_dev, c, a) -#define RX_STAT_INC(hif_dev, c) -#define RX_STAT_ADD(hif_dev, c, a) +#define TX_STAT_INC(hif_dev, c) do { } while (0) +#define TX_STAT_ADD(hif_dev, c, a) do { } while (0) +#define RX_STAT_INC(hif_dev, c) do { } while (0) +#define RX_STAT_ADD(hif_dev, c, a) do { } while (0) #define CAB_STAT_INC(priv) #define TX_QSTAT_INC(priv, c)