lib: checksum: hide unused expected_csum_ipv6_magic[]
PATCH v2 1/1 lib: checksum: hide unused expected_csum_ipv6_magic[]
From: Arnd Bergmann <[email protected]>
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=]
Replace the #ifdef with an IS_ENABLED() check that makes the compiler's dead-code-elimination take care of the link failure.
--- lib/checksum_kunit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/checksum_kunit.c +3 -2
@@ -594,13 +594,15 @@ static void test_ip_fast_csum(struct kunit *test)static void test_csum_ipv6_magic (struct kunit *test) { -#if defined(CONFIG_NET )const struct in6_addr *saddr;const struct in6_addr *daddr;unsigned int len;unsigned char proto;__wsum csum; +if (!IS_ENABLED (CONFIG_NET )) +return ; +const int daddr_offset =sizeof (struct in6_addr );const int len_offset =sizeof (struct in6_addr ) +sizeof (struct in6_addr ); const int proto_offset = sizeof(struct in6_addr) + sizeof(struct in6_addr) +
@@ -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 */ }static struct kunit_case __refdata checksum_test_cases[] = {
Signature · 1 line
2.39.2
Quoted 4 lines · On Thu, 4 Apr 2024 13:44:33 +0200 Arnd Bergmann wrote:
From: Arnd Bergmann <[email protected]>
When
CONFIG_NETis disabled, an extra warning shows up for this unused variable:
Happy for others to take this, but to avoid misunderstandings - if it's not on netdev@ we won't be able to apply.
Palmer Dabbelt
Acked-byQuoted 10 lines · On Thu, 04 Apr 2024 08:01:32 PDT (-0700), [email protected] wrote:
Quoted 4 lines · On Thu, 4 Apr 2024 13:44:33 +0200 Arnd Bergmann wrote:
From: Arnd Bergmann <[email protected]>
When
CONFIG_NETis disabled, an extra warning shows up for this unused variable:Happy for others to take this, but to avoid misunderstandings - if it's not on netdev@ we won't be able to apply.
Acked-by Jakub Kicinski <[email protected]>
Looks like you took the last one, do we need to just CC [email protected] ?
Quoted 6 lines · On Thu, 04 Apr 2024 09:23:57 -0700 (PDT) Palmer Dabbelt wrote:
Quoted 1 line
Acked-by Jakub Kicinski <[email protected]>Acked-by Palmer Dabbelt <[email protected]>Looks like you took the last one, do we need to just CC [email protected] ?
Yes, Arnd would need to resend to get it into our patchwork.