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.

drm/tests: Use KUNIT_DEFINE_ACTION_WRAPPER()

In order to pass functions to kunit_add_action(), they need to be of the
kunit_action_t type. While casting the function pointer can work, it
will break control-flow integrity.

drm_kunit_helpers already defines wrappers, but we now have a macro
which does this automatically. Using this greatly reduces the
boilerplate needed.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

David Gow and committed by
Shuah Khan
e847934b 56778b49

+9 -21
+9 -21
drivers/gpu/drm/tests/drm_kunit_helpers.c
··· 27 27 }, 28 28 }; 29 29 30 - static void kunit_action_platform_driver_unregister(void *ptr) 31 - { 32 - struct platform_driver *drv = ptr; 33 - 34 - platform_driver_unregister(drv); 35 - 36 - } 37 - 38 - static void kunit_action_platform_device_put(void *ptr) 39 - { 40 - struct platform_device *pdev = ptr; 41 - 42 - platform_device_put(pdev); 43 - } 44 - 45 - static void kunit_action_platform_device_del(void *ptr) 46 - { 47 - struct platform_device *pdev = ptr; 48 - 49 - platform_device_del(pdev); 50 - } 30 + KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_driver_unregister, 31 + platform_driver_unregister, 32 + struct platform_driver *); 33 + KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_put, 34 + platform_device_put, 35 + struct platform_device *); 36 + KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_platform_device_del, 37 + platform_device_del, 38 + struct platform_device *); 51 39 52 40 /** 53 41 * drm_kunit_helper_alloc_device - Allocate a mock device for a KUnit test