From ea363b0f9e07d65db66f7c0160f07fd3ba385875 Mon Sep 17 00:00:00 2001 From: zhangkaixiang Date: Wed, 12 Jul 2023 12:19:24 +0800 Subject: [PATCH] close dir fd in ioctl Signed-off-by: zhangkaixiang Change-Id: Ifed62e80db731caf1ff4f72d274e4eb60fdb470e --- interfaces/common/include/log.h | 2 +- .../native/remote_file_share/src/remote_file_share.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/interfaces/common/include/log.h b/interfaces/common/include/log.h index 207318f30..c941a611d 100644 --- a/interfaces/common/include/log.h +++ b/interfaces/common/include/log.h @@ -29,7 +29,7 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, APP_LOG_DOM #define LOGI(fmt, ...) PRINT_LOG(Info, fmt, ##__VA_ARGS__) #define LOGW(fmt, ...) PRINT_LOG(Warn, fmt, ##__VA_ARGS__) -#define LOGD(fmt, ...) PRINT_LOG(Warn, fmt, ##__VA_ARGS__) +#define LOGD(fmt, ...) PRINT_LOG(Debug, fmt, ##__VA_ARGS__) #define LOGE(fmt, ...) PRINT_LOG(Error, fmt, ##__VA_ARGS__) #define LOGF(fmt, ...) PRINT_LOG(Fatal, fmt, ##__VA_ARGS__) } // namespace AppFileService diff --git a/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp b/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp index dd20f224f..4d272b21a 100644 --- a/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp +++ b/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp @@ -333,9 +333,11 @@ int32_t RemoteFileShare::GetDfsUriFromLocal(const std::string &uriStr, const int ret = ioctl(dirFd, HMDFS_IOC_GET_DST_PATH, &hdi); if (ret != 0) { LOGE("Ioctl failed with %{public}d", errno); + close(dirFd); return -errno; } + close(dirFd); SetHmdfsUriInfo(hui, uri, hdi.size); LOGD("GetDfsUriFromLocal successfully with %{public}s", hui.uriStr.c_str()); return 0; -- Gitee