Skip to contentSkip to conversation

check info.exists to get valid value

PATCH Applied Vaughan Cao 2 participants 2 messages Jun 25, 2014 – Jul 1, 2014 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check info.exists to get valid value

dm_task_get_info will still return 1 if device doesn't exist. Check info.exists to ensure major and minor values are valid.

There is no reason to assign info.open_count to @r here.

---
 libmultipath/devmapper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
libmultipath/devmapper.c +1 -2
index 30e9351..3d4c111 100644
@@ -567,10 +567,9 @@ dm_dev_t (const char * mapname, char * dev_t, int len)
 	if (!dm_task_run(dmt))
 		goto out;
 
-	if (!dm_task_get_info(dmt, &info))
+	if (!dm_task_get_info(dmt, &info) || !info.exists)
 		goto out;
 
-	r = info.open_count;
 	if (snprintf(dev_t, len, "%i:%i", info.major, info.minor) > len)
 		    goto out;
 
Signature · 1 line
1.9.0
#1 lore raw

Applied.
Thanks.

Quoted 30 lines · Vaughan Cao

dm_task_get_info will still return 1 if device doesn't exist. Check info.exists to ensure major and minor values are valid.

There is no reason to assign info.open_count to @r here.

---
 libmultipath/devmapper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
libmultipath/devmapper.c +1 -3
index 30e9351..3d4c111 100644
@@ -567,10 +567,9 @@ dm_dev_t (const char * mapname, char * dev_t, int len)
        if (!dm_task_run(dmt))
                goto out;
 
-       if (!dm_task_get_info(dmt, &info))
+       if (!dm_task_get_info(dmt, &info) || !info.exists)
                goto out;
 
-       r = info.open_count;
        if (snprintf(dev_t, len, "%i:%i", info.major, info.minor) > len)
                    goto out;
 
--

1.9.0