Refactoring private function of TzipInterface::Pimpl 18/286318/1
authorilho kim <ilho159.kim@samsung.com>
Tue, 3 Jan 2023 12:56:05 +0000 (21:56 +0900)
committerilho kim <ilho159.kim@samsung.com>
Wed, 4 Jan 2023 00:25:07 +0000 (09:25 +0900)
"success" variable of IsMounted is meaningless

Change-Id: I5b0e0bff5c8811ab1614716702c051d75e1aa885
Signed-off-by: ilho kim <ilho159.kim@samsung.com>
src/common/tzip_interface.cc

index 26fabf2..0ce658e 100644 (file)
@@ -117,8 +117,8 @@ class TzipInterface::Pimpl {
     }
     g_variant_unref(r);
 
-    return WaitForCondition([=](bool *success)->bool {
-      return IsMounted(success);
+    return WaitForCondition([=]()->bool {
+      return IsMounted();
     });
   }
 
@@ -133,40 +133,36 @@ class TzipInterface::Pimpl {
     }
     g_variant_unref(r);
 
-    return WaitForCondition([=](bool *success)->bool {
-      return IsUnmounted(success);
+    return WaitForCondition([=]()->bool {
+      return IsUnmounted();
     });
   }
 
  private:
-  bool IsMounted(bool *success) {
+  bool IsMounted() {
     const char* mount_path_str = mount_path_.string().c_str();
     GVariant* r = dbus_proxy_->ProxyCallSync(kTzipIsMountedMethod,
         g_variant_new("(s)", mount_path_str));
-    if (!r) {
-      *success = false;
+    if (!r)
       return false;
-    }
 
     gint ret;
     g_variant_get(r, "(i)", &ret);
     g_variant_unref(r);
-    *success = true;
     return ret != 0;
   }
 
-  bool IsUnmounted(bool *success) {
-    return !IsMounted(success);
+  bool IsUnmounted() {
+    return !IsMounted();
   }
 
-  bool WaitForCondition(std::function<bool(bool*)> condition) {
+  bool WaitForCondition(std::function<bool()> condition) {
     if (!mount_path_.empty()) {
       bool rv = false;
       int cnt = 0;
       while (cnt < kTzipMountMaximumRetryCount) {
-        bool success;
-        rv = condition(&success);
-        if (rv && success)
+        rv = condition();
+        if (rv)
           break;
         sleep(1);
         cnt++;