diff --git a/interfaces/kits/native/recent/recent_n_exporter.cpp b/interfaces/kits/native/recent/recent_n_exporter.cpp index 762992f4eff5bd80884f5eab4b1b28827b5cc28f..be59d42bcb538e1176e961825a332adadc35e427 100644 --- a/interfaces/kits/native/recent/recent_n_exporter.cpp +++ b/interfaces/kits/native/recent/recent_n_exporter.cpp @@ -171,7 +171,7 @@ static int64_t GetFileMtime(const string &fileName) string filePath = RecentNExporter::recentPath_ + fileName; struct stat statBuf; if (lstat(filePath.c_str(), &statBuf) < 0) { - HILOG_ERROR("Failed to lstat uri, errno=%{public}d, fileName=%{public}s", errno, fileName.c_str()); + HILOG_ERROR("Failed to lstat uri, errno=%{public}d, fileName=%{private}s", errno, fileName.c_str()); return errno; } return static_cast(statBuf.st_mtime); @@ -181,7 +181,7 @@ static string GetName(const string &path) { auto pos = path.find_last_of('/'); if (pos == string::npos) { - HILOGE("Failed to split filename from path, path: %{public}s", path.c_str()); + HILOGE("Failed to split filename from path, path: %{private}s", path.c_str()); } return path.substr(pos + 1); } diff --git a/interfaces/kits/native/trash/src/file_trash_n_exporter.cpp b/interfaces/kits/native/trash/src/file_trash_n_exporter.cpp index dfb19a2e525bfd03a012e251c853fd5c3182110e..52da410004f5f018d248b2337b2bff93044cd2c8 100644 --- a/interfaces/kits/native/trash/src/file_trash_n_exporter.cpp +++ b/interfaces/kits/native/trash/src/file_trash_n_exporter.cpp @@ -185,7 +185,7 @@ static napi_value CreateObjectArray(napi_env env, vector result) static string FindSourceFilePath(const string &path) { - HILOG_INFO("FindSourceFilePath: curFilePath = %{public}s", path.c_str()); + HILOG_INFO("FindSourceFilePath: curFilePath = %{private}s", path.c_str()); size_t slashSize = 1; // 获取/trash目录位置 size_t trashPathPrefixPos = path.find(FileTrashNExporter::trashPath_); @@ -213,7 +213,7 @@ static string FindSourceFilePath(const string &path) string realFileName = realFilePath.substr(pos + TRASH_SUB_DIR.length() + timeSlot.length() + slashSize); realFilePath = "/" + realFilePathPrefix + realFileName; - HILOG_INFO("FindSourceFilePath: realFilePath After = %{public}s", realFilePath.c_str()); + HILOG_INFO("FindSourceFilePath: realFilePath After = %{private}s", realFilePath.c_str()); return realFilePath; } diff --git a/services/native/file_access_service/src/file_access_service.cpp b/services/native/file_access_service/src/file_access_service.cpp index 1b675930b82325faff93ab80e8a344d18a1f8d2f..93828f424f326e871b2d3d783c52d34793159b2c 100644 --- a/services/native/file_access_service/src/file_access_service.cpp +++ b/services/native/file_access_service/src/file_access_service.cpp @@ -307,17 +307,18 @@ int32_t FileAccessService::OperateObsNode(Uri &uri, bool notifyForDescendants, u { string uriStr = uri.ToString(); HILOG_INFO("OperateObsNode uriStr: %{public}s", uriStr.c_str()); - shared_ptr obsNode; { lock_guard lock(nodeMutex_); auto iter = relationshipMap_.find(uriStr); if (iter != relationshipMap_.end()) { - obsNode = iter->second; + auto obsNode = iter->second; // this node has this callback or not, if has this, unref manager. auto haveCodeIter = find_if(obsNode->obsCodeList_.begin(), obsNode->obsCodeList_.end(), [code](const uint32_t &listCode) { return code == listCode; }); if (haveCodeIter != obsNode->obsCodeList_.end()) { - obsManager_.get(code)->UnRef(); + if (obsManager_.get(code) != nullptr) { + obsManager_.get(code)->UnRef(); + } if (obsNode->needChildNote_ == notifyForDescendants) { HILOG_DEBUG("Register same uri and same callback and same notifyForDescendants"); return ERR_OK; @@ -340,7 +341,7 @@ int32_t FileAccessService::OperateObsNode(Uri &uri, bool notifyForDescendants, u extensionProxy->StartWatcher(uri); { lock_guard lock(nodeMutex_); - obsNode = make_shared(notifyForDescendants); + auto obsNode = make_shared(notifyForDescendants); // add new node relations. for (auto &[comUri, node] : relationshipMap_) { if (IsParentUri(comUri, uriStr)) {