Skip to contentSkip to conversation

master - cov: extent_size cannot be 0

PATCH Zdenek Kabelac 1 participant 1 message Dec 21, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=26ead4bf45e94e6cfee2036d1c0c800abf4344b3
Commit:        26ead4bf45e94e6cfee2036d1c0c800abf4344b3
Parent:        9dfb1a11b76282ed8f3819bf63c369b179fac78d
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri Dec 21 20:55:50 2018 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Dec 21 21:45:08 2018 +0100

cov: extent_size cannot be 0

Make this obvious to coverity.

---
 lib/metadata/cache_manip.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
lib/metadata/cache_manip.c +4 -1
index 6cf945b..656e49d 100644
@@ -1201,7 +1201,10 @@ int cache_single_set_params(struct cmd_context *cmd,
 	 * data size: the LV size minus the metadata size.
 	 */
 
-	extent_size = pool_lv->vg->extent_size;
+	if (!(extent_size = pool_lv->vg->extent_size)) {
+		log_error(INTERNAL_ERROR "Extend size can't be 0.");
+		return 0;
+	}
 	min_meta_size = extent_size;
 	max_meta_size = 2 * DEFAULT_CACHE_POOL_MAX_METADATA_SIZE; /* 2x for KiB to sectors */