test/dm: check if devices exist
Running 'ut dm' on the sandbox without -D or -d results in segmentation
faults due to NULL pointer dereferences.
Check that device pointers are non-NULL before using them.
Use ut_assertnonnull() for pointers instead of ut_assert().
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Philippe Reynes <philippe.reynes@softathome.com>
diff --git a/test/dm/core.c b/test/dm/core.c
index 6a930ae..d20c484 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -158,7 +158,7 @@
for (uclass_find_first_device(UCLASS_TEST, &dev);
dev;
uclass_find_next_device(&dev)) {
- ut_assert(dev);
+ ut_assertnonnull(dev);
uc_pdata = dev_get_uclass_platdata(dev);
ut_assert(uc_pdata);
@@ -181,7 +181,7 @@
for (uclass_find_first_device(UCLASS_TEST, &dev);
dev;
uclass_find_next_device(&dev)) {
- ut_assert(dev);
+ ut_assertnonnull(dev);
uc_pdata = dev_get_uclass_platdata(dev);
ut_assert(uc_pdata);
@@ -747,11 +747,11 @@
dev;
ret = uclass_find_next_device(&dev)) {
ut_assert(!ret);
- ut_assert(dev);
+ ut_assertnonnull(dev);
}
ut_assertok(uclass_find_first_device(UCLASS_TEST_DUMMY, &dev));
- ut_assert(!dev);
+ ut_assertnull(dev);
return 0;
}
@@ -778,7 +778,7 @@
testdev;
ret = uclass_find_next_device(&testdev)) {
ut_assertok(ret);
- ut_assert(testdev);
+ ut_assertnonnull(testdev);
findret = uclass_find_device_by_name(UCLASS_TEST_FDT,
testdev->name,