diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 602d9cd0e..5310d8ac4 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -899,10 +899,13 @@ static int _insert_dir(const char *dir) static int _dev_cache_iterate_devs_for_index(struct cmd_context *cmd) { - struct dev_iter *iter = dev_iter_create(NULL, 0); + struct dev_iter *iter; struct device *dev = NULL; int r = 1; + if (!(iter = dev_iter_create(NULL, 0))) + return_0; + while ((dev = dev_iter_get(NULL, iter))) if (!_index_dev_by_vgid_and_lvid(cmd, dev)) r = 0; @@ -1786,9 +1789,12 @@ struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt) struct device *dev_cache_get_by_pvid(struct cmd_context *cmd, const char *pvid) { - struct dev_iter *iter = dev_iter_create(NULL, 0); + struct dev_iter *iter; struct device *dev; + if (!(iter = dev_iter_create(NULL, 0))) + return_NULL; + while ((dev = dev_iter_get(NULL, iter))) if (!memcmp(dev->pvid, pvid, ID_LEN)) break; @@ -1868,9 +1874,12 @@ const char *dev_name(const struct device *dev) bool dev_cache_has_md_with_end_superblock(struct dev_types *dt) { struct device *dev; - struct dev_iter *iter = dev_iter_create(NULL, 0); + struct dev_iter *iter; bool ret = false; + if (!(iter = dev_iter_create(NULL, 0))) + return_false; + while ((dev = dev_iter_get(NULL, iter))) if ((ret = dev_is_md_with_end_superblock(dt, dev))) break; diff --git a/lib/log/log.h b/lib/log/log.h index b5f05f29b..2e97d7215 100644 --- a/lib/log/log.h +++ b/lib/log/log.h @@ -129,6 +129,7 @@ #define return_0 do { stack; return 0; } while (0) #define return_NULL do { stack; return NULL; } while (0) +#define return_false do { stack; return false; } while (0) #define return_EINVALID_CMD_LINE \ do { stack; return EINVALID_CMD_LINE; } while (0) #define return_ECMD_FAILED do { stack; return ECMD_FAILED; } while (0)