From 5b0597a7b22d283aca5edf9574b805b803f69b7b Mon Sep 17 00:00:00 2001 From: zhangkaixiang Date: Thu, 13 Apr 2023 20:16:16 +0800 Subject: [PATCH] remove some warnings Signed-off-by: zhangkaixiang --- .../native/file_share/include/file_share.h | 4 +-- .../native/file_share/src/file_share.cpp | 26 +++++++------- interfaces/kits/js/@ohos.remotefileshare.d.ts | 35 ------------------- .../kits/js/file_uri/get_uri_from_path.cpp | 2 +- .../src/remote_file_share.cpp | 2 +- 5 files changed, 17 insertions(+), 52 deletions(-) delete mode 100644 interfaces/kits/js/@ohos.remotefileshare.d.ts diff --git a/interfaces/innerkits/native/file_share/include/file_share.h b/interfaces/innerkits/native/file_share/include/file_share.h index 9e741cc4b..68cdf3db9 100644 --- a/interfaces/innerkits/native/file_share/include/file_share.h +++ b/interfaces/innerkits/native/file_share/include/file_share.h @@ -67,8 +67,8 @@ const vector LOWER_PATH = { class FileShare { public: FileShare() {} - static int32_t CreateShareFile(const string &uri, int32_t tokenId, int32_t flag); - static int32_t DeleteShareFile(int32_t tokenId, vector sharePathList); + static int32_t CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag); + static int32_t DeleteShareFile(uint32_t tokenId, vector sharePathList); ~FileShare() {} }; } // namespace AppFileService diff --git a/interfaces/innerkits/native/file_share/src/file_share.cpp b/interfaces/innerkits/native/file_share/src/file_share.cpp index df600bde5..3605cf38a 100644 --- a/interfaces/innerkits/native/file_share/src/file_share.cpp +++ b/interfaces/innerkits/native/file_share/src/file_share.cpp @@ -41,7 +41,7 @@ struct FileShareInfo { SHARE_FILE_TYPE type_; }; -static int32_t GetTargetInfo(int32_t tokenId, string &bundleName, string ¤tUid) +static int32_t GetTargetInfo(uint32_t tokenId, string &bundleName, string ¤tUid) { Security::AccessToken::HapTokenInfo hapInfo; int32_t result = Security::AccessToken::AccessTokenKit::GetHapTokenInfo(tokenId, hapInfo); @@ -99,7 +99,7 @@ static int32_t GetLowerPath(string &lowerPathHead, const string &lowerPathTail, return 0; } -static int32_t GetProviderPath(const string &uriStr, int32_t tokenId, FileShareInfo &info) +static int32_t GetProviderPath(const string &uriStr, FileShareInfo &info) { Uri uri(uriStr); string pathInProvider = uri.GetPath(); @@ -107,7 +107,7 @@ static int32_t GetProviderPath(const string &uriStr, int32_t tokenId, FileShareI if (pos == string::npos) { return -EINVAL; } - + size_t num = SANDBOX_PATH.size(); string lowerPathTail = "", lowerPathHead = ""; for (size_t i = 0; i < num; i++) { @@ -120,18 +120,18 @@ static int32_t GetProviderPath(const string &uriStr, int32_t tokenId, FileShareI } } } - + int32_t ret = GetLowerPath(lowerPathHead, lowerPathTail, info); if (ret != 0) { LOGE("Get lower path failed with %{public}d", ret); return ret; } - + info.providerSandboxPath_ = pathInProvider; return 0; } -static void GetSharePath(FileShareInfo &info, int32_t flag) +static void GetSharePath(FileShareInfo &info, uint32_t flag) { string shareRPath = DATA_APP_EL2_PATH + info.currentUid_ + SHARE_PATH +info.targetBundleName_ + SHARE_R_PATH + info.providerBundleName_ + info.providerSandboxPath_; @@ -160,7 +160,7 @@ static int32_t GetShareFileType(FileShareInfo &info) return -ENOENT; } -static int32_t GetFileShareInfo(const string &uri, int32_t tokenId, int32_t flag, FileShareInfo &info) +static int32_t GetFileShareInfo(const string &uri, uint32_t tokenId, uint32_t flag, FileShareInfo &info) { int32_t ret = 0; ret = GetTargetInfo(tokenId, info.targetBundleName_, info.currentUid_); @@ -168,9 +168,9 @@ static int32_t GetFileShareInfo(const string &uri, int32_t tokenId, int32_t flag LOGE("Failed to get target info %{public}d", ret); return ret; } - + GetProviderBundleName(uri, info.providerBundleName_); - ret = GetProviderPath(uri, tokenId, info); + ret = GetProviderPath(uri, info); if (ret != 0) { LOGE("Failed to get lower path %{public}d", ret); return ret; @@ -240,7 +240,7 @@ static bool RemoveDir(const string& path) } delDirs.pop(); } - + return true; } @@ -271,7 +271,7 @@ static int32_t PreparePreShareDir(FileShareInfo &info) return 0; } -int32_t FileShare::CreateShareFile(const string &uri, int32_t tokenId, int32_t flag) +int32_t FileShare::CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag) { FileShareInfo info; int32_t ret = GetFileShareInfo(uri, tokenId, flag, info); @@ -334,7 +334,7 @@ static void UmountDelUris(vector sharePathList, string currentUid, strin } } -int32_t FileShare::DeleteShareFile(int32_t tokenId, vector sharePathList) +int32_t FileShare::DeleteShareFile(uint32_t tokenId, vector sharePathList) { string bundleName, currentUid; int32_t ret = GetTargetInfo(tokenId, bundleName, currentUid); @@ -349,7 +349,7 @@ int32_t FileShare::DeleteShareFile(int32_t tokenId, vector sharePathList LOGE("Delete dir failed with %{public}d", errno); return -errno; } - + LOGI("Delete Share File Successfully!"); return 0; } diff --git a/interfaces/kits/js/@ohos.remotefileshare.d.ts b/interfaces/kits/js/@ohos.remotefileshare.d.ts deleted file mode 100644 index 28bc3eb38..000000000 --- a/interfaces/kits/js/@ohos.remotefileshare.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* Copyright (C) 2021-2023 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {AsyncCallback, Callback} from "./basic"; - -/** - * Provides remote file share APIs - * - * @since 10 - * @sysCap N/A - * @devices phone, tablet - */ -declare namespace Remotefileshare { - /** - * Create the remote share path of src share file. - * - * @since 10 - */ - function createSharePath(fd: number, cid: string, callback: AsyncCallback): void; - function createSharePath(fd: number, cid: string): Promise; -} - -export default Remotefileshare; diff --git a/interfaces/kits/js/file_uri/get_uri_from_path.cpp b/interfaces/kits/js/file_uri/get_uri_from_path.cpp index 30c77385a..58334177a 100644 --- a/interfaces/kits/js/file_uri/get_uri_from_path.cpp +++ b/interfaces/kits/js/file_uri/get_uri_from_path.cpp @@ -49,7 +49,7 @@ static string GetBundleName() { int uid = -1; uid = IPCSkeleton::GetCallingUid(); - + sptr bundleMgrProxy = GetBundleMgrProxy(); if (!bundleMgrProxy) { LOGE("GetBundleName: bundle mgr proxy is nullptr."); diff --git a/services/remote_file_share/src/remote_file_share.cpp b/services/remote_file_share/src/remote_file_share.cpp index 05be3c14d..4aa72792d 100644 --- a/services/remote_file_share/src/remote_file_share.cpp +++ b/services/remote_file_share/src/remote_file_share.cpp @@ -173,7 +173,7 @@ int RemoteFileShare::CreateSharePath(const int &fd, std::string &sharePath, LOGE("RemoteFileShare::CreateSharePath, invalid argument with %{public}d", EINVAL); return EINVAL; } - + const std::string processName = GetProcessName(); if (processName == "") { LOGE("RemoteFileShare::CreateSharePath, GetProcessName failed with %{public}d", errno); -- Gitee