[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <bdcabb75-f9a5-4905-90b4-2c9c2cf0588a@app.fastmail.com>
Date: Wed, 03 Apr 2024 10:58:00 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Christophe Leroy" <christophe.leroy@...roup.eu>,
"Arnd Bergmann" <arnd@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"Palmer Dabbelt" <palmer@...osinc.com>
Cc: "Dave Hansen" <dave.hansen@...ux.intel.com>,
"Noah Goldstein" <goldstein.w.n@...il.com>,
"Charlie Jenkins" <charlie@...osinc.com>
Subject: Re: [PATCH 18/34] lib: checksum: hide unused expected_csum_ipv6_magic[]
On Wed, Apr 3, 2024, at 10:41, Christophe Leroy wrote:
> Le 03/04/2024 à 10:06, Arnd Bergmann a écrit :
>> From: Arnd Bergmann <arnd@...db.de>
>>
>> When CONFIG_NET is disabled, an extra warning shows up for this
>> unused variable:
>>
>> lib/checksum_kunit.c:218:18: error: 'expected_csum_ipv6_magic' defined but not used [-Werror=unused-const-variable=]
>>
>> Hide it under the same #ifdef as the reference to it.
>>
>> Fixes: f24a70106dc1 ("lib: checksum: Fix build with CONFIG_NET=n")
>
> I think that commit introduced unjustified #ifdef in a C file.
> Refer
> https://docs.kernel.org/process/coding-style.html#conditional-compilation
>
> The fix should be:
>
> + if (!IS_ENABLED(CONFIG_NET))
> + return;
> +
> for (int i = 0; i < NUM_IPv6_TESTS; i++) {
> saddr = (const struct in6_addr *)(random_buf + i);
> daddr = (const struct in6_addr *)(random_buf + i +
> @@ -618,7 +620,6 @@ static void test_csum_ipv6_magic(struct kunit *test)
> CHECK_EQ(to_sum16(expected_csum_ipv6_magic[i]),
> csum_ipv6_magic(saddr, daddr, len, proto, csum));
> }
> -#endif /* !CONFIG_NET */
Yes, I usually prefer that approach, and I think I tried it first
but ran into compile-time problems because csum_ipv6_magic()
is declared conditionally. Let me try again, maybe I misremember
what I did or I can remove some more #ifdef checks for this.
Arnd
Powered by blists - more mailing lists