From patchwork Tue May 5 14:13:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 197777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 484F9C47254 for ; Tue, 5 May 2020 14:24:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CE0520746 for ; Tue, 5 May 2020 14:24:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729335AbgEEONs (ORCPT ); Tue, 5 May 2020 10:13:48 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:36933 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729146AbgEEONr (ORCPT ); Tue, 5 May 2020 10:13:47 -0400 Received: from localhost.localdomain ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M9WeC-1jSePQ0bES-005d0q; Tue, 05 May 2020 16:13:32 +0200 From: Arnd Bergmann To: "Jason A. Donenfeld" , "David S. Miller" Cc: Arnd Bergmann , Greg KH , Herbert Xu , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, wireguard@lists.zx2c4.com, clang-built-linux@googlegroups.com Subject: [PATCH] net: wireguard: avoid unused variable warning Date: Tue, 5 May 2020 16:13:17 +0200 Message-Id: <20200505141327.746184-1-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:j5rBKEs2EZ2wBWucgw3jP/snV64xmxjwf5JSJRK1981/0aQIMOW fEF0VkodfzvUsiuEQUDo7kxlEFs3xdtHubS7l8i8Gk1lEj/6nOgXOAI7UbeAobG1OrqBrcG GVJlqLnzIGLXPiv/nvBYUAcfTh4xKECz/6lRIBaCKcqauCArBacxGzmbeG17O3z256yLxp7 bPL+EwTM3HZElCMzzbHdg== X-UI-Out-Filterresults: notjunk:1; V03:K0:Dk/GUQ/t1Bc=:yEMm/AYZhCfPtA9HWgU3/6 NpaeDf8tJN2PXbUfTPSlKnW7zxCFyXGgCxtknT8672D1Ri8glQ0ejXiFdUI0VLfBoZxCu5ZDq Clbq9XIaw4vcoS70Z2oe1OASZcipm0xIj+Zd/sSDeKE8gTibGvA7lKu5AMxc3kJh2lauU4eO0 2VZryiFexozDS0SJoW6iZ6r2J2I7RNXCG9q5S3XNMZEHyPZxOUTh7XKocmbX2dBzzUCYOYkob ImIbtdgQxuidwLOPtuVokmY/B19rUsAtrBJQavK1pXZUX9zUsmDM1rl6/9jg9JmEWtZYQdHJj +3AnWXN2FG9EqRAhc3HC73C63I/UyhuLDh2+lBinSTdkgGdPQ1TNh58+2id0y4BPR06U8R23C CAB8mOJeJI1VXb2BGa7qb8GxLRBTBqGJotvhWYSel4/A+YrG7hjLIlsAvodsTEb0dEV61D5l5 INqNgLWCH3tuiIYBOTpfgiCSB8qU83C9eMU5oClxOZAEpyJjjsLdxi+qSrpIUixWyJbMjM25b NjnrlxnZUtn2Z3CAdaNw786GgKxn3jw80kwrk6Onysd02XylVd4HeN6QAUsczkoyc1CD4L9zK 2ktIYnX4devlUErlwVSGJzrPp+U9YNrHIcGTuM/KMRD3KzIH9+zjoDIVQ3AtpjcnZnuR4NQnt oYRKBcLtwnw/1EJFvNfQsdavWNOOzKnjXIa8BXi8RM980R6bmIOG3PRpoR/waCc+FYsBccfA6 xLLw98YqKlcnpnG0+v8pwD98Lv0jX+sbOtb4b3JZeVJm0LO7sik3VgKCtlEjzeXI8AbKWOwCk bvmJu2G6jNC4yXyi8EScJuTfM7t46CimQURKtQRg4qvTNma43E= Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org clang points out a harmless use of uninitialized variables that get passed into a local function but are ignored there: In file included from drivers/net/wireguard/ratelimiter.c:223: drivers/net/wireguard/selftest/ratelimiter.c:173:34: error: variable 'skb6' is uninitialized when used here [-Werror,-Wuninitialized] ret = timings_test(skb4, hdr4, skb6, hdr6, &test_count); ^~~~ drivers/net/wireguard/selftest/ratelimiter.c:123:29: note: initialize the variable 'skb6' to silence this warning struct sk_buff *skb4, *skb6; ^ = NULL drivers/net/wireguard/selftest/ratelimiter.c:173:40: error: variable 'hdr6' is uninitialized when used here [-Werror,-Wuninitialized] ret = timings_test(skb4, hdr4, skb6, hdr6, &test_count); ^~~~ drivers/net/wireguard/selftest/ratelimiter.c:125:22: note: initialize the variable 'hdr6' to silence this warning struct ipv6hdr *hdr6; ^ Shut up the warning by ensuring the variables are always initialized, and make up for the loss of readability by changing the "#if IS_ENABLED()" checks to regular "if (IS_ENABLED())". Fixes: e7096c131e51 ("net: WireGuard secure network tunnel") Signed-off-by: Arnd Bergmann --- drivers/net/wireguard/selftest/ratelimiter.c | 32 +++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireguard/selftest/ratelimiter.c b/drivers/net/wireguard/selftest/ratelimiter.c index bcd6462e4540..f408b936e224 100644 --- a/drivers/net/wireguard/selftest/ratelimiter.c +++ b/drivers/net/wireguard/selftest/ratelimiter.c @@ -153,19 +153,22 @@ bool __init wg_ratelimiter_selftest(void) skb_reset_network_header(skb4); ++test; -#if IS_ENABLED(CONFIG_IPV6) - skb6 = alloc_skb(sizeof(struct ipv6hdr), GFP_KERNEL); - if (unlikely(!skb6)) { - kfree_skb(skb4); - goto err_nofree; + if (IS_ENABLED(CONFIG_IPV6)) { + skb6 = alloc_skb(sizeof(struct ipv6hdr), GFP_KERNEL); + if (unlikely(!skb6)) { + kfree_skb(skb4); + goto err_nofree; + } + skb6->protocol = htons(ETH_P_IPV6); + hdr6 = (struct ipv6hdr *)skb_put(skb6, sizeof(*hdr6)); + hdr6->saddr.in6_u.u6_addr32[0] = htonl(1212); + hdr6->saddr.in6_u.u6_addr32[1] = htonl(289188); + skb_reset_network_header(skb6); + ++test; + } else { + skb6 = NULL; + hdr6 = NULL; } - skb6->protocol = htons(ETH_P_IPV6); - hdr6 = (struct ipv6hdr *)skb_put(skb6, sizeof(*hdr6)); - hdr6->saddr.in6_u.u6_addr32[0] = htonl(1212); - hdr6->saddr.in6_u.u6_addr32[1] = htonl(289188); - skb_reset_network_header(skb6); - ++test; -#endif for (trials = TRIALS_BEFORE_GIVING_UP;;) { int test_count = 0, ret; @@ -206,9 +209,8 @@ bool __init wg_ratelimiter_selftest(void) err: kfree_skb(skb4); -#if IS_ENABLED(CONFIG_IPV6) - kfree_skb(skb6); -#endif + if (IS_ENABLED(CONFIG_IPV6)) + kfree_skb(skb6); err_nofree: wg_ratelimiter_uninit(); wg_ratelimiter_uninit();