Fix static analysis issue 69/296669/2
authorilho kim <ilho159.kim@samsung.com>
Thu, 3 Aug 2023 02:36:39 +0000 (11:36 +0900)
committerilho kim <ilho159.kim@samsung.com>
Thu, 3 Aug 2023 06:15:12 +0000 (15:15 +0900)
'std::time_t' to 'long' may or may not override sign-bit depending on
size of implementation defined type
which may cause unexpected results on porting to different platforms

Change-Id: I2267cb80f68545433bfe742e432a471013645d94
Signed-off-by: ilho kim <ilho159.kim@samsung.com>
src/rpk/step/configuration/step_parse_rpk_manifest.cc

index e987ba2a97a39576f68dc85369032022fe71205e..e95368f29b3c098748d785e16267b91a7b6720f1 100644 (file)
 #include <rpk_manifest_handlers/dependencies_handler.h>
 #include <rpk_manifest_handlers/package_handler.h>
 
-#include <chrono>
 #include <string>
 
 #include <common/installer_context.h>
 #include <common/step/step.h>
 #include "common/utils/paths.h"
 #include "common/utils/pkgmgr_query.h"
+#include "common/utils/time_util.h"
 
 namespace bf = boost::filesystem;
 
@@ -418,9 +418,7 @@ bool StepParseRpkManifest::FillDependencyInfo(manifest_x* manifest) {
 bool StepParseRpkManifest::FillInstallationInfo(manifest_x* manifest) {
   manifest->root_path = strdup(
       (context_->root_application_path.get() / manifest->package).c_str());
-  manifest->installed_time =
-      strdup(std::to_string(std::chrono::system_clock::to_time_t(
-          std::chrono::system_clock::now())).c_str());
+  manifest->installed_time = strdup(common_installer::GetCurrentTime().c_str());
   return true;
 }