Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sysctl: call sysctl tests with a for loop

As we add more test functions in lib/tests_sysctl the main test function
(test_sysctl_init) grows. Condense the logic to make it easier to
add/remove tests.

Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>

+10 -18
+10 -18
lib/test_sysctl.c
··· 301 301 302 302 static int __init test_sysctl_init(void) 303 303 { 304 - int err; 304 + int err = 0; 305 305 306 - err = test_sysctl_setup_node_tests(); 307 - if (err) 308 - goto out; 306 + int (*func_array[])(void) = { 307 + test_sysctl_setup_node_tests, 308 + test_sysctl_run_unregister_nested, 309 + test_sysctl_run_register_mount_point, 310 + test_sysctl_run_register_empty, 311 + test_sysctl_register_u8_extra 312 + }; 309 313 310 - err = test_sysctl_run_unregister_nested(); 311 - if (err) 312 - goto out; 314 + for (int i = 0; !err && i < ARRAY_SIZE(func_array); i++) 315 + err = func_array[i](); 313 316 314 - err = test_sysctl_run_register_mount_point(); 315 - if (err) 316 - goto out; 317 - 318 - err = test_sysctl_run_register_empty(); 319 - if (err) 320 - goto out; 321 - 322 - err = test_sysctl_register_u8_extra(); 323 - 324 - out: 325 317 return err; 326 318 } 327 319 module_init(test_sysctl_init);