diff --git a/services/storage_daemon/crypto/src/base_key.cpp b/services/storage_daemon/crypto/src/base_key.cpp index bc053ca6876a4e752eacf75c67d33ae52fcb39bf..d29b2ebd507170daaeccb213c894dde360516531 100644 --- a/services/storage_daemon/crypto/src/base_key.cpp +++ b/services/storage_daemon/crypto/src/base_key.cpp @@ -697,7 +697,7 @@ bool BaseKey::DoRestoreKey(const UserAuth &auth, const std::string &path) std::error_code errCode; std::string need_restore; LoadStringFromFile(path + SUFFIX_NEED_RESTORE, need_restore); - uint32_t restore_version = std::atoi(need_restore.c_str()); + uint32_t restore_version = static_cast(std::atoi(need_restore.c_str())); UpdateVersion update_version = static_cast(std::atoi(need_restore.c_str())); LOGI("NeedRestore Path is: %{public}s, restore_version: %{public}u", path.c_str(), restore_version); if (std::filesystem::exists(path + SUFFIX_NEED_RESTORE, errCode)) { diff --git a/services/storage_daemon/ipc/src/storage_daemon.cpp b/services/storage_daemon/ipc/src/storage_daemon.cpp index ab92fc1e9a10991575bb34c419cfaa418c78909b..e9613feba2ccb55822d5533dff6fcb44973418ee 100644 --- a/services/storage_daemon/ipc/src/storage_daemon.cpp +++ b/services/storage_daemon/ipc/src/storage_daemon.cpp @@ -694,7 +694,7 @@ int32_t StorageDaemon::PrepareUserDirsAndUpdateUserAuthVx(uint32_t userId, KeyTy return ret; } std::string need_restore_path = KeyManager::GetInstance()->GetKeyDirByUserAndType(userId, type) + RESTORE_DIR; - uint32_t new_need_restore = std::atoi(needRestoreVersion.c_str()) + 1; + uint32_t new_need_restore = static_cast(std::atoi(needRestoreVersion.c_str()) + 1); if (new_need_restore == UpdateVersion::UPDATE_V4 && !SaveStringToFileSync(need_restore_path, std::to_string(new_need_restore))) { LOGE("Write userId: %{public}d, El%{public}d need_restore failed.", userId, type); diff --git a/services/storage_daemon/mtpfs/src/mtpfs_fuse.cpp b/services/storage_daemon/mtpfs/src/mtpfs_fuse.cpp index 18a475c07dcd1ec5eb3216d7e27e3c492c9e3beb..adc6488852437a767d6848891236c5499350fa28 100644 --- a/services/storage_daemon/mtpfs/src/mtpfs_fuse.cpp +++ b/services/storage_daemon/mtpfs/src/mtpfs_fuse.cpp @@ -579,7 +579,7 @@ int MtpFileSystem::ReName(const char *path, const char *newpath, unsigned int fl const int32_t factor = 1000; auto now = std::chrono::system_clock::now(); auto millisecs = std::chrono::duration_cast(now.time_since_epoch()); - uint64_t time = millisecs.count() / factor; + time_t time = static_cast(millisecs.count() / factor); if (dirParent != nullptr) { LOGI("MtpFileSystem: file cutted, update dirParent mtime"); const_cast(dirParent)->SetModificationDate(time); @@ -689,9 +689,11 @@ int MtpFileSystem::Open(const char *path, struct fuse_file_info *fileInfo) LOGE("Missing FileInfo"); return -ENOENT; } - if (static_cast(fileInfo->flags) & O_WRONLY) { - static_cast(fileInfo->flags) |= O_TRUNC; + unsigned int flags = static_cast(fileInfo->flags); + if (flags & O_WRONLY) { + flags |= O_TRUNC; } + fileInfo->flags = static_cast(flags); const std::string stdPath(path); MtpFsTypeTmpFile *tmpFile = const_cast(tmpFilesPool_.GetFile(stdPath)); diff --git a/services/storage_daemon/mtpfs/src/mtpfs_mtp_device.cpp b/services/storage_daemon/mtpfs/src/mtpfs_mtp_device.cpp index 56f396ae6bcd5977a394850b5998eba5d4a21c52..37e8f0dc61f43f9d60cba3d099d9935f0bb8422d 100644 --- a/services/storage_daemon/mtpfs/src/mtpfs_mtp_device.cpp +++ b/services/storage_daemon/mtpfs/src/mtpfs_mtp_device.cpp @@ -277,11 +277,11 @@ const MtpFsTypeDir *MtpFsDevice::DirFetchContent(std::string path) static uint64_t GetFormattedTimestamp() { - const int32_t secFactor = 1000; + const int64_t secFactor = 1000; auto now = std::chrono::system_clock::now(); auto millisecs = std::chrono::duration_cast(now.time_since_epoch()); - uint64_t milliSeconds = millisecs.count(); - return milliSeconds / secFactor; + uint64_t milliSeconds = static_cast(millisecs.count() / secFactor); + return milliSeconds; } int MtpFsDevice::DirCreateNew(const std::string &path) diff --git a/services/storage_daemon/mtpfs/src/mtpfs_util.cpp b/services/storage_daemon/mtpfs/src/mtpfs_util.cpp index baf476a07591ac73c2e8d98095e340e7d5e4b667..c5fa8db76fe6fba5dd03af200d3db51f0cf8541a 100644 --- a/services/storage_daemon/mtpfs/src/mtpfs_util.cpp +++ b/services/storage_daemon/mtpfs/src/mtpfs_util.cpp @@ -119,28 +119,10 @@ std::string SmtpfsGetTmpDir() { const char *cTmp = "/data/local/mtp_tmp"; OHOS::StorageDaemon::DelTemp(cTmp); - std::string tmpDir; - if (cTmp) { - tmpDir = SmtpfsRealPath(cTmp); - } else { - cTmp = getenv("TMPDIR"); - if (!cTmp) { - cTmp = TMPDIR; - } - tmpDir = SmtpfsRealPath(cTmp); - } - tmpDir += "/simple-mtpfs-XXXXXX"; - char *cTmpDir = ::strdup(tmpDir.c_str()); - if (cTmpDir == nullptr) { - return ""; - } - char *cTmpDirFree = ::mkdtemp(cTmpDir); - if (cTmpDirFree == nullptr) { - ::free(static_cast(cTmpDir)); - return ""; - } + std::string tmpDir = SmtpfsRealPath(cTmp) + "/simple-mtpfs-XXXXXX"; + char *cTmpDir = ::mkdtemp(::strdup(tmpDir.c_str())); tmpDir.assign(cTmpDir); - ::free(static_cast(cTmpDirFree)); + ::free(static_cast(cTmpDir)); return tmpDir; } diff --git a/services/storage_manager/storage/src/storage_monitor_service.cpp b/services/storage_manager/storage/src/storage_monitor_service.cpp index 597ac3331168a9e5249463a7e1afd2c8f06c0465..77e298dd3de1104b388dd8ad43140c209b69228a 100644 --- a/services/storage_manager/storage/src/storage_monitor_service.cpp +++ b/services/storage_manager/storage/src/storage_monitor_service.cpp @@ -182,7 +182,7 @@ void StorageMonitorService::CleanBundleCacheByInterval(const std::string ×t LOGI("Not found timestamp from system parameter"); return; } - uint64_t lastCleanCacheTime = std::stoull(param); + uint64_t lastCleanCacheTime = static_cast(std::atoll(param.c_str())); auto duration = std::chrono::duration_cast(currentTime - std::chrono::system_clock::time_point(std::chrono::hours(lastCleanCacheTime))).count(); LOGI("CleanBundleCache timestamp is %{public}s, duration is %{public}ld", timestamp.c_str(), duration);