From 127c2fc6e287f0f7edb9c0a061aaaba31bf47e45 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 10 Mar 2021 14:05:03 +0100 Subject: [PATCH] lv_check_not_in_use: correct check Since lv_info() may return 0 without setting info struct, make the test correct and even more readable. --- lib/activate/activate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/activate/activate.c b/lib/activate/activate.c index c450eab14..4452d4d40 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -834,8 +834,10 @@ int lv_check_not_in_use(const struct logical_volume *lv, int error_if_used) struct lvinfo info; unsigned int open_count_check_retries; - if (!lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) || !info.exists || !info.open_count) - return !info.exists ? 2 : 1; + if (!lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) || !info.exists) + return 2; + else if (!info.open_count) + return 1; /* If sysfs is not used, use open_count information only. */ if (dm_sysfs_dir()) {