Fix coding rule 30/175730/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 12 Apr 2018 04:21:49 +0000 (13:21 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 18 Apr 2018 11:06:15 +0000 (11:06 +0000)
Change-Id: Ib31ba9f6e9f500a396fb46137309cda00de32e91
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/certificate_validation.cc
src/common/step/security/step_save_signature.cc

index 61c4161dd29e3fc04537fb6ee59f57a2171ecb0c..216d1d355ecdc1bd3980673fe1f24a8a85b42475 100644 (file)
@@ -94,11 +94,11 @@ bool SetDistributor2Certificate(const ValidationCore::SignatureData& data,
       false);
 }
 
-bool SetSignature(std::ifstream& ifs,
+bool SetSignature(std::ifstream* ifs,
     ValidationCore::CertificatePtr* certificate,
     std::string* cert_str) {
   std::string cert;
-  std::getline(ifs, cert);
+  std::getline(*ifs, cert);
   if (cert.length() != 0) {
     ValidationCore::CertificatePtr cert_ptr(
         new ValidationCore::Certificate(
@@ -110,7 +110,7 @@ bool SetSignature(std::ifstream& ifs,
   return true;
 }
 
-bool ReadSignature(std::ifstream& ifs,
+bool ReadSignature(std::ifstream* ifs,
     ValidationCore::CertificatePtr* cert,
     ValidationCore::CertificatePtr* im_cert,
     ValidationCore::CertificatePtr* root_cert,
@@ -283,12 +283,12 @@ bool GetSignatureFromFile(const std::string& pkgid,
     return false;
   }
 
-  if (!ReadSignature(ifs,
+  if (!ReadSignature(&ifs,
           &cert_info->dist2_cert.get(),
           &cert_info->dist2_im_cert.get(),
           &cert_info->dist2_root_cert.get(),
           &root_cert) ||
-      !ReadSignature(ifs,
+      !ReadSignature(&ifs,
           &cert_info->dist_cert.get(),
           &cert_info->dist_im_cert.get(),
           &cert_info->dist_root_cert.get(),
index 2430ed517ea2d75ff9e428847230e02a6bfec867..2734aafdf8845314aedf1a90e0baedcc274e8a7f 100644 (file)
@@ -19,20 +19,20 @@ namespace bf = boost::filesystem;
 
 namespace {
 
-bool StoreSignature(std::ofstream& ofs,
-    ValidationCore::CertificatePtr& cert,
-    ValidationCore::CertificatePtr& im_cert,
-    ValidationCore::CertificatePtr& root_cert) {
+bool StoreSignature(std::ofstream* ofs,
+    const ValidationCore::CertificatePtr& cert,
+    const ValidationCore::CertificatePtr& im_cert,
+    const ValidationCore::CertificatePtr& root_cert) {
   if (!ofs)
     return false;
 
-  ofs << ((cert) ? cert->getBase64().c_str() : "") << std::endl;
-  ofs << ((im_cert) ? im_cert->getBase64().c_str() : "") << std::endl;
-  ofs << ((root_cert) ? root_cert->getBase64().c_str() : "") << std::endl;
+  *ofs << ((cert) ? cert->getBase64().c_str() : "") << std::endl;
+  *ofs << ((im_cert) ? im_cert->getBase64().c_str() : "") << std::endl;
+  *ofs << ((root_cert) ? root_cert->getBase64().c_str() : "") << std::endl;
   return true;
 }
 
-bool RemoveSignature(bf::path& path) {
+bool RemoveSignature(const bf::path& path) {
   for (bf::directory_iterator file(path);
       file != bf::directory_iterator();
       ++file) {
@@ -59,7 +59,7 @@ bool RemoveSignature(bf::path& path) {
   return true;
 }
 
-} // namespace
+}  // namespace
 
 namespace common_installer {
 namespace security {
@@ -93,11 +93,11 @@ Step::Status StepSaveSignature::process() {
 
   std::ofstream ofs(signature_filepath.c_str(),
       std::ios::out | std::ios::trunc);
-  if (!StoreSignature(ofs,
+  if (!StoreSignature(&ofs,
                       cert_info.dist2_cert.get(),
                       cert_info.dist2_im_cert.get(),
                       cert_info.dist2_root_cert.get()) ||
-      !StoreSignature(ofs,
+      !StoreSignature(&ofs,
                       cert_info.dist_cert.get(),
                       cert_info.dist_im_cert.get(),
                       cert_info.dist_root_cert.get()))