PM: runtime: Fix error checking for kunit_device_register()
Subsystems (5)
PATCH 1/1 PM: runtime: Fix error checking for kunit_device_register()
The kunit_device_register() function never returns NULL, it returns error pointers. Update the assertions to use KUNIT_ASSERT_NOT_ERR_OR_NULL() instead of checking for NULL.
Fixes 7f7acd193ba8 ("PM: runtime: Add basic kunit tests for API contracts")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/base/power/runtime-test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/base/power/runtime-test.c +6 -6
@@ -14,7 +14,7 @@ static void pm_runtime_depth_test(struct kunit *test) {struct device *dev =kunit_device_register (test,DEVICE_NAME ); -KUNIT_ASSERT_PTR_NE (test,NULL , dev); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev);pm_runtime_enable (dev);
@@ -32,7 +32,7 @@ static void pm_runtime_already_suspended_test(struct kunit *test) {struct device *dev =kunit_device_register (test,DEVICE_NAME ); -KUNIT_ASSERT_PTR_NE (test,NULL , dev); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev);pm_runtime_enable (dev);KUNIT_EXPECT_TRUE (test,pm_runtime_suspended (dev));
@@ -70,7 +70,7 @@ static void pm_runtime_idle_test(struct kunit *test) {struct device *dev =kunit_device_register (test,DEVICE_NAME ); -KUNIT_ASSERT_PTR_NE (test,NULL , dev); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev);pm_runtime_enable (dev);
@@ -91,7 +91,7 @@ static void pm_runtime_disabled_test(struct kunit *test) {struct device *dev =kunit_device_register (test,DEVICE_NAME ); -KUNIT_ASSERT_PTR_NE (test,NULL , dev); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev);/* Never called pm_runtime_enable() */ KUNIT_EXPECT_FALSE (test,pm_runtime_enabled (dev));
@@ -131,7 +131,7 @@ static void pm_runtime_error_test(struct kunit *test) {struct device *dev =kunit_device_register (test,DEVICE_NAME ); -KUNIT_ASSERT_PTR_NE (test,NULL , dev); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev);pm_runtime_enable (dev);KUNIT_EXPECT_TRUE (test,pm_runtime_suspended (dev));
@@ -214,7 +214,7 @@ static void pm_runtime_probe_active_test(struct kunit *test) {struct device *dev =kunit_device_register (test,DEVICE_NAME ); -KUNIT_ASSERT_PTR_NE (test,NULL , dev); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev);KUNIT_EXPECT_TRUE (test,pm_runtime_status_suspended (dev));
Signature · 1 line
2.51.0
Quoted 6 lines · Dan Carpenter
The
kunit_device_register()function never returns NULL, it returns error pointers. Update the assertions to useKUNIT_ASSERT_NOT_ERR_OR_NULL()instead of checking for NULL.Fixes 7f7acd193ba8 ("PM: runtime: Add basic kunit tests for API contracts")Signed-off-by Dan Carpenter <[email protected]>
Thanks for the catch:
Reviewed-by Brian Norris <[email protected]>
Quoted 6 lines · Brian Norris
Quoted 4 lines · Dan Carpenter
The
kunit_device_register()function never returns NULL, it returns error pointers. Update the assertions to useKUNIT_ASSERT_NOT_ERR_OR_NULL()instead of checking for NULL.
Quoted 6 lines
Quoted 2 lines
Fixes 7f7acd193ba8 ("PM: runtime: Add basic kunit tests for API contracts")Signed-off-by Dan Carpenter <[email protected]>Thanks for the catch:
Reviewed-by Brian Norris <[email protected]>
Applied, thanks!