small fixes 94/58094/3
authorPawel Sikorski <p.sikorski@samsung.com>
Wed, 27 Jan 2016 11:36:52 +0000 (12:36 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 27 Jan 2016 13:43:29 +0000 (05:43 -0800)
* fix cppcheck warnings
* fix compilation warnings
* removing some old TODOs

Change-Id: I5d8c3f24720cb33d471401784d27e405f4b3fc4b

src/common/app_installer.cc
src/common/pkgmgr_registration.cc
src/common/step/step_check_signature.cc
src/common/step/step_configure.cc
src/common/step/step_copy.cc
src/common/step/step_delta_patch.cc
src/pkgdir_tool/pkgdir_tool.cc

index 76eaeca..9e3b0ee 100644 (file)
@@ -24,8 +24,6 @@ AppInstaller::AppInstaller(const char* package_type, PkgMgrPtr pkgmgr)
   pi_.reset(new PkgmgrSignal(pkgmgr.get()->GetRawPi(),
                              pkgmgr->GetRequestType()));
 
-  // TODO(p.sikorski) below property is only used in AppInstaller.
-  // maybe it should then be kept in AppInstaller
   context_->pkg_type.set(package_type);
   context_->installation_mode.set(pkgmgr->GetInstallationMode());
 }
index a923826..b1f10ab 100644 (file)
@@ -61,7 +61,7 @@ int PkgmgrForeachPrivilegeCallback(const char* privilege_name,
   return PMINFO_R_OK;
 }
 
-bool AssignPackageTags(const std::string& pkgid, manifest_x* manifest,
+bool AssignPackageTags(manifest_x* manifest,
                        common_installer::RequestMode request_mode,
                        bool is_update) {
   // this flag is actually set by preloaded app update to "true" but it is never
@@ -96,7 +96,7 @@ bool RegisterAppInPkgmgr(manifest_x* manifest,
   if (!tep_path.empty())
     manifest->tep_name = strdup(tep_path.c_str());
 
-  if (!AssignPackageTags(pkgid, manifest, request_mode, false))
+  if (!AssignPackageTags(manifest, request_mode, false))
     return false;
 
   int ret = request_mode != RequestMode::GLOBAL ?
@@ -141,7 +141,7 @@ bool UpgradeAppInPkgmgr(manifest_x* manifest,
                         const CertificateInfo& cert_info,
                         uid_t uid,
                         RequestMode request_mode) {
-  if (!AssignPackageTags(pkgid, manifest, request_mode, true))
+  if (!AssignPackageTags(manifest, request_mode, true))
     return false;
 
   int ret = request_mode != RequestMode::GLOBAL ?
index a6a1af1..2cebeec 100644 (file)
@@ -89,19 +89,17 @@ common_installer::Step::Status ValidateSignatureFile(
   *error_message += ":<" + errnum + ">";
 
   switch (result) {
-    case ValidationCore::E_SIG_REVOKED: {
+    case ValidationCore::E_SIG_REVOKED:
       LOG(ERROR) << "Certificate is revoked";
       return common_installer::Step::Status::SIGNATURE_INVALID;
-    };
-    case ValidationCore::E_SIG_DISREGARDED: {
+    case ValidationCore::E_SIG_DISREGARDED:
         if (data.isAuthorSignature()) {
           LOG(ERROR) << "Author-signiture is disregarded";
           return common_installer::Step::Status::SIGNATURE_INVALID;
         }
         LOG(WARNING) << "Signature disregarded: " << path;
         break;
-    };
-    case ValidationCore::E_SIG_NONE: {
+    case ValidationCore::E_SIG_NONE:
       if (!data.isAuthorSignature()) {
         // First distributor signature sets the privilege level
         // (wrt spec. 0620.)
@@ -114,12 +112,10 @@ common_installer::Step::Status ValidateSignatureFile(
         cert_info->author_certificate.set(data.getEndEntityCertificatePtr());
       }
       break;
-    };
-    default: {
+    default:
       LOG(ERROR) << "signature validation check failed : "
                  << validator.errorToString(result);
       return common_installer::Step::Status::SIGNATURE_INVALID;
-    };
   }
   return common_installer::Step::Status::OK;
 }
index 236cba1..2799892 100644 (file)
@@ -85,7 +85,6 @@ Step::Status StepConfigure::process() {
       break;
     }
     default:
-      // TODO(p.sikorski): should return unsupported, and display error
       LOG(ERROR) <<
           "Only installation, update and uninstallation is now supported";
       return Status::CONFIG_ERROR;
index 1cb3956..875b54b 100644 (file)
@@ -50,8 +50,6 @@ Step::Status StepCopy::precheck() {
     return Step::Status::PACKAGE_NOT_FOUND;
   }
 
-  // TODO(p.sikorski) asserts?
-
   return Step::Status::OK;
 }
 
index efd3bdf..a4c6e76 100644 (file)
@@ -90,18 +90,18 @@ bool ApplyModifiedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
       LOG(ERROR) << "Cannot modify. Not a regular file: " << input;
       return false;
     }
-    const char* const argv[] = {
-      kXDeltaBinary,
-      "-d",
-      "-s",
-      input.c_str(),
-      patch_file.c_str(),
-      temp_file.c_str(),
-      nullptr,
-    };
     pid_t pid = fork();
     if (pid == 0) {
-    int ret = execv(argv[0], const_cast<char* const*>(argv));
+      const char* const argv[] = {
+        kXDeltaBinary,
+        "-d",
+        "-s",
+        input.c_str(),
+        patch_file.c_str(),
+        temp_file.c_str(),
+        nullptr,
+      };
+      int ret = execv(argv[0], const_cast<char* const*>(argv));
       if (ret != 0) {
         // no other thing to -> do just quit
         exit(-1);
index 763ebec..23466e5 100644 (file)
@@ -209,7 +209,6 @@ bool CreateSkelDirectories(const std::string& pkgid) {
   LOG(DEBUG) << "Creating directories in: " << path;
   bs::error_code error;
   bf::create_directories(path, error);
-  int r = -1;
 
   if (error) {
     LOG(ERROR) << "Failed to create directory: " << path;
@@ -226,7 +225,8 @@ bool CreateSkelDirectories(const std::string& pkgid) {
       return false;
     }
 
-    r = lsetxattr(subpath.c_str(), "security.SMACK64TRANSMUTE", "TRUE", 4, 0);
+    int r =
+        lsetxattr(subpath.c_str(), "security.SMACK64TRANSMUTE", "TRUE", 4, 0);
     if (r < 0) {
       LOG(ERROR) << "Failed to apply transmute";
       return false;