diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..6c198d1858ed365f3e17b6021e25cec94a77d83c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "map": "cpp", + "memory": "cpp" + } +} \ No newline at end of file diff --git a/OAT.xml b/OAT.xml index 54fc1b978e6261a7f39bf38ca02a0b2d50ad609c..43ffcf501444f6ab72b854db27da9bbf2a041090 100644 --- a/OAT.xml +++ b/OAT.xml @@ -12,7 +12,8 @@ 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. - + --> + diff --git a/display/@ohos.distributedHardware.deviceManager.d.ts b/display/@ohos.distributedHardware.deviceManager.d.ts index d00376306a92181187afa2623d4f18fff21648cd..791537728153955953143993125f7491814d0909 100644 --- a/display/@ohos.distributedHardware.deviceManager.d.ts +++ b/display/@ohos.distributedHardware.deviceManager.d.ts @@ -16,7 +16,7 @@ import { AsyncCallback, Callback } from './basic'; /** - * Providers interfaces to creat a {@link deviceManager} instances. + * Providers interfaces to create a {@link deviceManager} instances. * * @since 7 * @Syscap SystemCapability.DISTRIBUTEDHARDWARE.deviceManager diff --git a/display/entry/build.gradle b/display/entry/build.gradle index 9cdfe117adf8796e13f28ba4c8f22db83c56d37f..127dec4068f8b66508c4b5709ccfa4fd35207460 100644 --- a/display/entry/build.gradle +++ b/display/entry/build.gradle @@ -13,7 +13,7 @@ * limitations under the License. */ - apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.hap' apply plugin: 'com.huawei.ohos.decctest' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { diff --git a/display/settings.gradle b/display/settings.gradle index 4773db73233a570c2d0c01a22e75321acfbf7a07..585467a7ab9732b60b7a13ea55692081b62412ae 100644 --- a/display/settings.gradle +++ b/display/settings.gradle @@ -1 +1,17 @@ +/* + * Copyright (c) 2022 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. + */ + + // Top-level build file where you can add configuration options common to all sub-projects/modules. include ':entry' diff --git a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp index d24031c7fff9ff2292d85e8248c4db795bac5284..711d56fe265bb876853c7b245fd1a17693fffc01 100644 --- a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp +++ b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp @@ -544,7 +544,7 @@ void DeviceManagerModule::JsToDmBuffer(const JSIValue &object, data = JSI::GetTypedArrayInfo(field, type, length, buffer, offset); if (type != TypedArrayType::JSI_UINT8_ARRAY || length == 0 || data == nullptr) { - DMLOG(DM_LOG_ERROR, "Invaild AppIconInfo"); + DMLOG(DM_LOG_ERROR, "Invalid AppIconInfo"); return; } *bufferPtr = (uint8_t*)calloc(sizeof(uint8_t), length); @@ -818,7 +818,7 @@ JSIValue DeviceManagerModule::StartDeviceDiscoverSync(const JSIValue thisVal, co } if (!JSI::ValueIsObject(args[0])){ - DMLOG(DM_LOG_ERROR, "a object is required."); + DMLOG(DM_LOG_ERROR, "an object is required."); return JSI::CreateNull(); } @@ -895,12 +895,12 @@ JSIValue DeviceManagerModule::AuthenticateDevice(const JSIValue thisVal, const J } if (!JSI::ValueIsObject(args[0])){ - DMLOG(DM_LOG_ERROR, "a object is required."); + DMLOG(DM_LOG_ERROR, "an object is required."); return JSI::CreateNull(); } if (!JSI::ValueIsObject(args[1])){ - DMLOG(DM_LOG_ERROR, "a object is required."); + DMLOG(DM_LOG_ERROR, "an object is required."); return JSI::CreateNull(); } @@ -948,7 +948,7 @@ JSIValue DeviceManagerModule::VerifyAuthInfo(const JSIValue thisVal, const JSIVa } if (!JSI::ValueIsObject(args[0])){ - DMLOG(DM_LOG_ERROR, "a object is required."); + DMLOG(DM_LOG_ERROR, "an object is required."); return JSI::CreateNull(); } diff --git a/ext/mini/sa_profile/4802.xml b/ext/mini/sa_profile/4802.xml index fce565731312857aef4c433154e05f2d5deb8524..3400882398acea4b5d25575d685eae5000497217 100644 --- a/ext/mini/sa_profile/4802.xml +++ b/ext/mini/sa_profile/4802.xml @@ -15,11 +15,11 @@ --> foundation - + 4802 libdevicemanagerservice.z.so - + true false 1 diff --git a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp index 55e986ac487735e5be1c9d5c57d3da3556d2d7d1..6fa2b1966cb58eea2b45ebf4002e0d544802e8b4 100644 --- a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp +++ b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp @@ -217,7 +217,7 @@ void HichainConnector::RegisterConnectorCallback(std::shared_ptrSetErrCode(ret); break; } diff --git a/ext/mini/services/devicemanagerservice/src/message/msg_request_auth.cpp b/ext/mini/services/devicemanagerservice/src/message/msg_request_auth.cpp index 6531b0c12c262dbcd95df5a6bb2d51e55bd51c03..c6ca4234029ec5589f8a67a51c293908a0d4cf60 100644 --- a/ext/mini/services/devicemanagerservice/src/message/msg_request_auth.cpp +++ b/ext/mini/services/devicemanagerservice/src/message/msg_request_auth.cpp @@ -115,7 +115,7 @@ void MsgRequestAuth::GetDecodeAppInfo(const std::string appString, uint8_t **out int32_t ret = EncryptUtils::MbedtlsBase64Decode(buffer, tempBufLen, &outLen, (const uint8_t*)appString.c_str(), appString.length()); if (ret != 0 || static_cast(outLen) > tempBufLen) { - DMLOG(DM_LOG_ERROR, "MbedtlsBase64Decode failed, ret %d, outLen %d, tempBufLen %d", + DMLOG(DM_LOG_ERROR, "MbedtlsBase64Decode failed, ret %d, outLen %zu, tempBufLen %d", ret, outLen, tempBufLen); outBufferLen = 0; *outBuffer = nullptr; @@ -352,6 +352,10 @@ void MsgRequestAuth::SetAuthType(nlohmann::json &json, std::shared_ptrmAuthType_ = authType; } diff --git a/ext/mini/services/devicemanagerservice/src/requestauth/response_session.cpp b/ext/mini/services/devicemanagerservice/src/requestauth/response_session.cpp index 2334fe0b126e3f71a2103e31c37ba92311bff5b2..f909026867e26dd4bf4b9a3a99c16bace5a0a4c8 100644 --- a/ext/mini/services/devicemanagerservice/src/requestauth/response_session.cpp +++ b/ext/mini/services/devicemanagerservice/src/requestauth/response_session.cpp @@ -99,7 +99,7 @@ void ResponseSession::OnUserOperate(int32_t action) break; } case FaAction::USER_OPERATION_TYPE_CANCEL_PINCODE_DISPLAY: { - DMLOG(DM_LOG_ERROR, "cancle pincode display"); + DMLOG(DM_LOG_ERROR, "cancel pincode display"); Release(); break; } diff --git a/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp b/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp index 65b138fe842b5fb5fae1c434a4d1999896334d25..e899e3580798df5ed18b78546a6983f16a74ce5b 100644 --- a/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp +++ b/ext/mini/services/devicemanagerservice/src/timer/dm_timer.cpp @@ -34,7 +34,7 @@ DmTimer::DmTimer(std::string &name) DmTimer::~DmTimer() { - DMLOG(DM_LOG_INFO, "DmTimer %s Destory in", mTimerName_.c_str()); + DMLOG(DM_LOG_INFO, "DmTimer %s Destroy in", mTimerName_.c_str()); Release(); } @@ -91,7 +91,6 @@ int32_t DmTimer::CreateTimeFd() void DmTimer::Release() { - DMLOG(DM_LOG_INFO, "DmTimer %s Release in", mTimerName_.c_str()); if (mStatus_ == DmTimerStatus::DM_STATUS_INIT) { DMLOG(DM_LOG_INFO, "DmTimer %s already Release", mTimerName_.c_str()); return; diff --git a/ext/mini/test/unittest/device_manager_impl_test.cpp b/ext/mini/test/unittest/device_manager_impl_test.cpp index b0073fdece14c0c59d343c3d11e08f931ef42ad3..789f2b2d3593059b88db57949d4dcd1f2b7e6e38 100644 --- a/ext/mini/test/unittest/device_manager_impl_test.cpp +++ b/ext/mini/test/unittest/device_manager_impl_test.cpp @@ -180,6 +180,7 @@ void DeviceDiscoverCallback::OnDiscoverFailed(uint16_t subscribeId, int32_t fail void DeviceDiscoverCallback::OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) { (void)subscribeId; + (void)deviceInfo; } } // namespace Vsync } // namespace OHOS diff --git a/ext/mini/utils/src/log/dm_log.cpp b/ext/mini/utils/src/log/dm_log.cpp index 202c20641913185d3eea36de06d8498e42474cf2..491c372444b68839627e6cca67617215d9327840 100644 --- a/ext/mini/utils/src/log/dm_log.cpp +++ b/ext/mini/utils/src/log/dm_log.cpp @@ -74,7 +74,7 @@ void DMLog(DMLogLevel logLevel, const char *fmt, ...) char logBuf[LOG_MAX_LEN] = {0}; va_list arg; - int32_t ret = (void)memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); + int32_t ret = memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); if (ret != 0) { DMLogOut(logLevel, "DM log memset_s error."); return; diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp index 4a92a1090b88fb169106eedbade0941da1046c8e..3b89b67f4a932624e55f3f08e13482341abec554 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp @@ -63,6 +63,10 @@ int32_t IpcClientManager::UnInit(const std::string &pkgName) } std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); + if (req == nullptr) { + LOGE("req is null"); + return DM_FAILED; + } req->SetPkgName(pkgName); int32_t ret = serverProxy_.SendCmd(UNREGISTER_DEVICE_MANAGER_LISTENER, req, rsp); if (ret != DM_OK) { diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index 984e12af1f17b6193454c5d068e605003951a9e7..3cb76e3620fdfacefb9191be4c398989e891fe33 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -57,6 +57,10 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &reply, std::shared_ptr pBaseRsp) { + if (pBaseRsp == nullptr) { + LOGE("pBaseRsp is null"); + return DM_FAILED; + } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; } @@ -105,6 +109,10 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_pt pDmDeviceinfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo)); if (pDmDeviceinfo == nullptr) { LOGE("GetTrustedDeviceList read node info failed!"); + if (pRsp == nullptr) { + LOGE("pRsp is null"); + return DM_FAILED; + } pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED); return DM_IPC_TRANSACTION_FAILED; } @@ -221,6 +229,10 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr pBaseReq, Messa ON_IPC_READ_RESPONSE(STOP_DEVICE_DISCOVER, MessageParcel &reply, std::shared_ptr pBaseRsp) { + if (pBaseRsp == nullptr) { + LOGE("pBaseRsp is null"); + return DM_FAILED; + } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; } @@ -255,6 +267,10 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, Messag ON_IPC_READ_RESPONSE(AUTHENTICATE_DEVICE, MessageParcel &reply, std::shared_ptr pBaseRsp) { + if (pBaseRsp == nullptr) { + LOGE("pBaseRsp is null"); + return DM_FAILED; + } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index 9eb01d88efea857a89a1db7052b70d337330f560..5081c63b51b5265b4be30b2ff514631acb3e6194 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -250,6 +250,10 @@ void DeviceManagerNotify::OnAuthResult(const std::string &pkgName, const std::st LOGE("DeviceManager OnAuthResult: no register authCallback for deviceID "); return; } + if (iter->second == nullptr) { + LOGE("DeviceManager OnAuthResult: no register authCallback for OnAuthResult "); + return; + } iter->second->OnAuthResult(deviceId, token, status, (int32_t)reason); authenticateCallback_[pkgName].erase(deviceId); if (authenticateCallback_[pkgName].empty()) { diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index e07993ec5bd483f98a0ae541810b338b86fe0aac..14380584232d960e2afe3bf1963dd452b50cddda 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -623,7 +623,11 @@ std::string DeviceManagerNapi::JsObjectToString(const napi_env &env, const napi_ if (buf == nullptr) { return ""; } - memset_s(buf, (size + 1), 0, (size + 1)); + int32_t ret = memset_s(buf, (size + 1), 0, (size + 1)); + if (ret != 0) { + LOGE("devicemanager memset_s error."); + return ""; + } bool rev = napi_get_value_string_utf8(env, param, buf, size + 1, &size) == napi_ok; std::string value; @@ -769,7 +773,7 @@ void DeviceManagerNapi::JsToDmBuffer(const napi_env &env, const napi_value &obje uint8_t *data = nullptr; napi_get_typedarray_info(env, field, &type, &length, reinterpret_cast(&data), &buffer, &offset); if (type != napi_uint8_array || length == 0 || data == nullptr) { - LOGE("Invaild AppIconInfo"); + LOGE("Invalid AppIconInfo"); return; } *bufferPtr = (uint8_t *)calloc(sizeof(uint8_t), length); diff --git a/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp b/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp index 2059069c6e0dcbadc93063fdf8051294050d3130..ee5a186016414f5db498ef884607df6258ab91c8 100644 --- a/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp +++ b/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp @@ -50,7 +50,7 @@ AbilityStatus DmAbilityManager::StartAbility(AbilityRole role) AAFwk::AbilityManagerClient::GetInstance()->Connect(); ErrCode result = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want); if (result != OHOS::ERR_OK) { - LOGE("Start Ability faild"); + LOGE("Start Ability failed"); mStatus_ = AbilityStatus::ABILITY_STATUS_FAILED; return mStatus_; } diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index ce60e6b8de154eef96e4786255ccf7e83cf0d12e..42d84b46c859cb7dd3928a678d8a66867d5c65c8 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -350,7 +350,7 @@ int32_t HiChainConnector::GetRelatedGroups(std::string deviceId, std::vectorgetRelatedGroups(userId, DM_PKG_NAME.c_str(), deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { - LOGE("HiChainConnector::GetRelatedGroups faild , ret: %d.", ret); + LOGE("HiChainConnector::GetRelatedGroups failed , ret: %d.", ret); return DM_FAILED; } if (returnGroups == nullptr) { diff --git a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp index 10f95633398067b342ac4b4feed28352ef043bac..7ac2eb0253c9e8331999a5d3ac56bb3f79c62daa 100644 --- a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp +++ b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp @@ -24,6 +24,7 @@ namespace DistributedHardware { namespace { const int32_t MILL_SECONDS_PER_SECOND = 1000; } + DmTimer::DmTimer(const std::string &name) { if (name.empty()) { diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp index b390d80f05929c3c812c8488b235364a71813e9a..d8b4e62e76cd6d80dd4275ae96ea20240e9e5968 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp @@ -44,6 +44,10 @@ ON_IPC_SET_REQUEST(SERVER_DEVICE_STATE_NOTIFY, std::shared_ptr pBaseReq, ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, IpcIo &reply, std::shared_ptr pBaseRsp) { + if (pBaseRsp == nullptr) { + LOGE("pBaseRsp is null"); + return DM_FAILED; + } pBaseRsp->SetErrCode(IpcIoPopInt32(&reply)); return DM_OK; } @@ -65,6 +69,10 @@ ON_IPC_SET_REQUEST(SERVER_DEVICE_FOUND, std::shared_ptr pBaseReq, IpcIo ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, IpcIo &reply, std::shared_ptr pBaseRsp) { + if (pBaseRsp == nullptr) { + LOGE("pBaseRsp is null"); + return DM_FAILED; + } pBaseRsp->SetErrCode(IpcIoPopInt32(&reply)); return DM_OK; } diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index 7e5805940860f690711af8f28d2c100617afc5bc..9bb72de1a136268398f8b7a9b69a736b3ec1f454 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp @@ -104,14 +104,14 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply) LOGE("malloc length invalid!"); return DM_MALLOC_ERROR; } - char *pkgName = (char *)malloc(len + 1); - if (pkgName == NULL) { + char *pkgName = new char[len+1]; + if (pkgName == nullptr) { LOGE("malloc failed!"); return DM_MALLOC_ERROR; } if (strcpy_s(pkgName, len + 1, (const char *)name) != DM_OK) { LOGE("strcpy_s failed!"); - free(pkgName); + delete[] pkgName; return DM_COPY_FAILED; } uint32_t cbId = 0; diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp index efb4c71b92b97dfc9fbeee88469a81eea8154cd9..81dcc23992fa2ba14f14b386464e6d43551ad14f 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp @@ -40,6 +40,10 @@ int32_t IpcServerListener::SendAll(int32_t cmdCode, std::shared_ptr req, auto remote = iter.second; req->SetPkgName(pkgName); sptr listener = iface_cast(remote); + if (listener == nullptr) { + LOGI("cannot get listener for package:%s.", pkgName.c_str()); + return DM_FAILED; + } listener->SendCmd(cmdCode, req, rsp); } return DM_OK; diff --git a/test/unittest/device_manager_impl_test.cpp b/test/unittest/device_manager_impl_test.cpp index 2d26d657fda3ac5a874a9159e88e5b8db0229a89..ead0313149f1696364eedc6ded0235bd738e10ce 100644 --- a/test/unittest/device_manager_impl_test.cpp +++ b/test/unittest/device_manager_impl_test.cpp @@ -187,6 +187,7 @@ void DeviceDiscoveryCallback::OnDiscoveryFailed(uint16_t subscribeId, int32_t fa void DeviceDiscoveryCallback::OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) { (void)subscribeId; + (void)deviceInfo; } } // namespace DistributedHardware } // namespace OHOS diff --git a/test/unittest/mock/device_auth.cpp b/test/unittest/mock/device_auth.cpp index f8d8bfaee1754505e575d244ac096c886ee29358..c3076a3d4e7c13f3a81a9eabe3a4fd13c2de387c 100644 --- a/test/unittest/mock/device_auth.cpp +++ b/test/unittest/mock/device_auth.cpp @@ -27,6 +27,10 @@ int32_t (*deleteGroup)(int64_t requestId, const char *appId, const char *disband int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char **returnGroupVec, uint32_t *groupNum) { + (void)appId; + (void)peerDeviceId; + (void)returnGroupVec; + (void)groupNum; return 0; } @@ -35,6 +39,8 @@ int32_t (*createGroup)(int64_t requestId, const char *appId, const char *createP if (requestId == 0) { return DM_FAILED; } + (void)appId; + (void)createParams; return 0; } @@ -52,4 +58,4 @@ int32_t (*getRelatedGroups)(const char *appId, const char *peerDeviceId, char ** groupNum = 1; returnGroupVec = "123"; } -} \ No newline at end of file +} diff --git a/test/unittest/mock/ipc_server_listener.cpp b/test/unittest/mock/ipc_server_listener.cpp index 6b139581168ca4df3d53abae982fe3a10ba7e642..0c70d88ae3fc91240cf0d0bdfc622a50a0ff2f4d 100644 --- a/test/unittest/mock/ipc_server_listener.cpp +++ b/test/unittest/mock/ipc_server_listener.cpp @@ -18,15 +18,17 @@ namespace OHOS { namespace DistributedHardware { int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { + (void)cmdCode; req_ = req; return 0; } int32_t IpcServerListener::SendAll(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { + (void)cmdCode; req_ = req; std::cout << req_->GetPkgName() << "\n"; return 0; } } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/test/unittest/mock/parameter.cpp b/test/unittest/mock/parameter.cpp index 0b552be589d1588aab4912eabb223eded8a93946..d6718efe68e498297167a0f8c2abfdacf5736aac 100644 --- a/test/unittest/mock/parameter.cpp +++ b/test/unittest/mock/parameter.cpp @@ -17,20 +17,30 @@ int GetParameter(const char *key, const char *def, char *value, unsigned int len) { + (void)key; + (void)def; + (void)value; + (void)len; return 0; } int SetParameter(const char *key, const char *value) { + (void)key; + (void)value; return 0; } int WatchParameter(const char *keyprefix, ParameterChgPtr callback, void *context) { + (void)keyprefix; + (void)context; return 0; } int GetDevUdid(char *udid, int size) { + (void)udid; + (void)size; return 0; -} \ No newline at end of file +} diff --git a/test/unittest/mock/softbus_bus_center.cpp b/test/unittest/mock/softbus_bus_center.cpp index b0ff12f89e487c52bf0939de05fa6e18c33416e2..6c55bca6ec9268f0c0c203aa453f957fdde5e58e 100644 --- a/test/unittest/mock/softbus_bus_center.cpp +++ b/test/unittest/mock/softbus_bus_center.cpp @@ -18,15 +18,25 @@ int32_t GetNodeKeyInfo(const char *pkgName, const char *networkId, NodeDeviceInfoKey key, uint8_t *info, int32_t infoLen) { + (void)pkgName; + (void)networkId; + (void)key; + (void)info; + (void)infoLen; return 0; } int32_t RegNodeDeviceStateCb(const char *pkgName, INodeStateCb *callback) { + (void)pkgName; + (void)callback; return 0; }; int32_t GetAllNodeDeviceInfo(const char *pkgName, NodeBasicInfo **info, int32_t *infoNum) { + (void)pkgName; + (void)info; + (void)infoNum; return 0; -} \ No newline at end of file +} diff --git a/utils/src/dm_log.cpp b/utils/src/dm_log.cpp index f17b08e8fad09723855ca8e160d90a3c52c7e424..898f1afaf69b575ae152e11c5e59639c358c4f30 100644 --- a/utils/src/dm_log.cpp +++ b/utils/src/dm_log.cpp @@ -73,9 +73,11 @@ void DmLog(DmLogLevel logLevel, const char *fmt, ...) { char logBuf[LOG_MAX_LEN] = {0}; va_list arg; - int32_t ret = 0; - - (void)memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); + int32_t ret = memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); + if (ret != 0) { + DmLogOut(logLevel, "DM log memset_s error."); + return; + } va_start(arg, fmt); ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); va_end(arg);