Skip to content

Commit e9d47b7

Browse files
arndbdavem330
authored andcommitted
lib: checksum: hide unused expected_csum_ipv6_magic[]
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. Fixes: f24a701 ("lib: checksum: Fix build with CONFIG_NET=n") Suggested-by: Christophe Leroy <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Simon Horman <[email protected]> # build-tested Signed-off-by: David S. Miller <[email protected]>
1 parent bccb798 commit e9d47b7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/checksum_kunit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,13 +594,15 @@ static void test_ip_fast_csum(struct kunit *test)
594594

595595
static void test_csum_ipv6_magic(struct kunit *test)
596596
{
597-
#if defined(CONFIG_NET)
598597
const struct in6_addr *saddr;
599598
const struct in6_addr *daddr;
600599
unsigned int len;
601600
unsigned char proto;
602601
__wsum csum;
603602

603+
if (!IS_ENABLED(CONFIG_NET))
604+
return;
605+
604606
const int daddr_offset = sizeof(struct in6_addr);
605607
const int len_offset = sizeof(struct in6_addr) + sizeof(struct in6_addr);
606608
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)
618620
CHECK_EQ(to_sum16(expected_csum_ipv6_magic[i]),
619621
csum_ipv6_magic(saddr, daddr, len, proto, csum));
620622
}
621-
#endif /* !CONFIG_NET */
622623
}
623624

624625
static struct kunit_case __refdata checksum_test_cases[] = {

0 commit comments

Comments
 (0)