Skip to contentSkip to conversation

master - coverity: check for info pointer existance

PATCH Zdenek Kabelac 1 participant 1 message Feb 23, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b08eb91df132e84fa41b4cf06707629b2c5c895e
Commit:        b08eb91df132e84fa41b4cf06707629b2c5c895e
Parent:        2e168a52b07bb9dc659bdcda80fc77031edebbd6
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Feb 23 19:48:01 2016 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Feb 23 21:40:16 2016 +0100

coverity: check for info pointer existance

Since we already check in few other places 'info' is not NULL, do the same for others - however when info would be NULL it more or less looks like internal error.

---
 lib/cache/lvmetad.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
lib/cache/lvmetad.c +4 -2
index b68e6c9..a483e04 100644
@@ -1062,14 +1062,16 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
 		return_0;
 	}
 
+	/* TODO: resolve what does it actually mean  'info == NULL'
+	 *       missing info is likely an INTERNAL_ERROR */
 	if (!config_make_nodes(pvmeta, pvmeta->root, NULL,
 			       "device = %"PRId64, (int64_t) dev->dev,
 			       "dev_size = %"PRId64, (int64_t) (info ? lvmcache_device_size(info) : 0),
 			       "format = %s", fmt->name,
 			       "label_sector = %"PRId64, (int64_t) label_sector,
 			       "id = %s", uuid,
-			       "ext_version = %"PRId64, (int64_t) lvmcache_ext_version(info),
-			       "ext_flags = %"PRId64, (int64_t) lvmcache_ext_flags(info),
+			       "ext_version = %"PRId64, (int64_t) (info ? lvmcache_ext_version(info) : 0),
+			       "ext_flags = %"PRId64, (int64_t) (info ? lvmcache_ext_flags(info) : 0),
 			       NULL))
 	{
 		dm_config_destroy(pvmeta);