]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lib: checksum: use ARRAY_SIZE() to improve assert_setup_correct()
authorThorsten Blum <thorsten.blum@toblux.com>
Fri, 26 Jul 2024 15:49:46 +0000 (17:49 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 2 Sep 2024 03:43:30 +0000 (20:43 -0700)
Use ARRAY_SIZE() to simplify the assert_setup_correct() function and
improve its readability.

Link: https://lkml.kernel.org/r/20240726154946.230928-1-thorsten.blum@toblux.com
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/checksum_kunit.c

index 4e4d081a1d3b060174d30bf217148667f5235477..be04aa42125cec29bad2d7c07dbcc0e2caca4426 100644 (file)
@@ -468,12 +468,9 @@ static __wsum to_wsum(u32 x)
 
 static void assert_setup_correct(struct kunit *test)
 {
-       CHECK_EQ(sizeof(random_buf) / sizeof(random_buf[0]), MAX_LEN);
-       CHECK_EQ(sizeof(expected_results) / sizeof(expected_results[0]),
-                MAX_LEN);
-       CHECK_EQ(sizeof(init_sums_no_overflow) /
-                        sizeof(init_sums_no_overflow[0]),
-                MAX_LEN);
+       CHECK_EQ(ARRAY_SIZE(random_buf), MAX_LEN);
+       CHECK_EQ(ARRAY_SIZE(expected_results), MAX_LEN);
+       CHECK_EQ(ARRAY_SIZE(init_sums_no_overflow), MAX_LEN);
 }
 
 /*