Fix static analyzer issue 45/119745/1
authorSangyoon Jang <s89.jang@samsung.com>
Mon, 20 Mar 2017 04:16:48 +0000 (13:16 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Mon, 20 Mar 2017 04:17:32 +0000 (13:17 +0900)
Change-Id: Id75dac30a64d63fbef55d26bd742db4f77ee88dc
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/pkg_recovery/pkg_recovery_helper.cc

index c9edbdd..e12c573 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by an apache-2.0 license that can be
 // found in the LICENSE file.
 
+#include <boost/filesystem/exception.hpp>
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/path.hpp>
 #include <boost/system/error_code.hpp>
@@ -84,9 +85,13 @@ bool DoRecoveryProcess(uid_t uid) {
   for (bf::directory_iterator iter(recovery_dir);
       iter != bf::directory_iterator();
       ++iter) {
-    bs::error_code error;
-    if (bf::is_directory(iter->path(), error))
+    try {
+      if (bf::is_directory(iter->path()))
+        continue;
+    } catch (const bf::filesystem_error& e) {
+      LOG(ERROR) << "Failed to get is_directory result: " << e.what();
       continue;
+    }
     std::string file = iter->path().filename().string();
     std::regex recovery_regex(kRecoveryFilePattern);
     std::smatch match;