diff --git a/src/cachedev.rs b/src/cachedev.rs index 2da362b8d..d8a0309a7 100644 --- a/src/cachedev.rs +++ b/src/cachedev.rs @@ -714,8 +714,7 @@ impl CacheDev { /// Get the current status of the cache device. pub fn status(&self, dm: &DM) -> DmResult { - let (_, status) = dm.table_status(&DevId::Name(self.name()), &DmOptions::new())?; - get_status(&status)?.parse() + status!(self, dm) } } diff --git a/src/shared_macros.rs b/src/shared_macros.rs index c5662591f..b5af542e1 100644 --- a/src/shared_macros.rs +++ b/src/shared_macros.rs @@ -47,3 +47,13 @@ macro_rules! table { &$s.table }; } + +macro_rules! status { + ($s:ident, $dm:ident) => { + get_status( + &$dm.table_status(&DevId::Name($s.name()), &DmOptions::new())? + .1, + )? + .parse() + }; +} diff --git a/src/thindev.rs b/src/thindev.rs index 2f9f21cd6..61808d194 100644 --- a/src/thindev.rs +++ b/src/thindev.rs @@ -381,8 +381,7 @@ impl ThinDev { /// Get the current status of the thin device. pub fn status(&self, dm: &DM) -> DmResult { - let (_, table) = dm.table_status(&DevId::Name(self.name()), &DmOptions::new())?; - get_status(&table)?.parse() + status!(self, dm) } /// Set the table for the thin device's target diff --git a/src/thinpooldev.rs b/src/thinpooldev.rs index d63bcd5e8..3c2d8f6ee 100644 --- a/src/thinpooldev.rs +++ b/src/thinpooldev.rs @@ -548,8 +548,7 @@ impl ThinPoolDev { /// Get the current status of the thinpool. /// Returns an error if there was an error getting the status value. pub fn status(&self, dm: &DM) -> DmResult { - let (_, status) = dm.table_status(&DevId::Name(self.name()), &DmOptions::new())?; - get_status(&status)?.parse() + status!(self, dm) } /// Set the table for the existing metadata device.