Fix static analyzer issues 34/118234/1
authorSangyoon Jang <s89.jang@samsung.com>
Thu, 9 Mar 2017 08:51:36 +0000 (17:51 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Thu, 9 Mar 2017 08:51:36 +0000 (17:51 +0900)
Change-Id: I6c8c5dcda1ca9b71d8476807802dfc50cdd6f873
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/pkg_recovery/pkg_recovery_helper.cc

index 29598df..c9edbdd 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/path.hpp>
-#include <boost/regex.hpp>
+#include <boost/system/error_code.hpp>
 
 #include <unistd.h>
 #include <sys/types.h>
 #include <common/request.h>
 #include <common/utils/user_util.h>
 
+#include <regex>
 #include <string>
 #include <iostream>
 
 namespace bf = boost::filesystem;
+namespace bs = boost::system;
 namespace ci = common_installer;
 
 namespace {
@@ -82,12 +84,13 @@ bool DoRecoveryProcess(uid_t uid) {
   for (bf::directory_iterator iter(recovery_dir);
       iter != bf::directory_iterator();
       ++iter) {
-    if (bf::is_directory(iter->path()))
+    bs::error_code error;
+    if (bf::is_directory(iter->path(), error))
       continue;
     std::string file = iter->path().filename().string();
-    boost::regex recovery_regex(kRecoveryFilePattern);
-    boost::smatch match;
-    if (boost::regex_match(file, match, recovery_regex)) {
+    std::regex recovery_regex(kRecoveryFilePattern);
+    std::smatch match;
+    if (std::regex_search(file, match, recovery_regex)) {
       LOG(INFO) << "Found recovery file: " << file;
       std::string type(match[1]);
       if (!RequestRecoveryService(uid, type.c_str(), iter->path().c_str()))
@@ -104,6 +107,6 @@ int main() {
   uid_t uid = getuid();
   DoRecoveryProcess(uid);
   if (ci::IsAdminUser(uid))
-    DoRecoveryProcess(tzplatform_getuid(TZ_SYS_GLOBALAPP_USER));
+    DoRecoveryProcess(kGlobalUserUid);
   return 0;
 }