From aee9e42cf53d110ea843dcb7d18e771cc8bb9b97 Mon Sep 17 00:00:00 2001 From: qinlong Date: Wed, 12 Oct 2022 17:37:50 +0800 Subject: [PATCH] =?UTF-8?q?cppCheck=E9=97=AE=E9=A2=98=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qinlong --- .../handlerinitsink_fuzzer/initsink_fuzzer.cpp | 2 +- .../subscribelocalhardware_fuzzer.cpp | 2 +- .../unsubscribelocalhardware_fuzzer.cpp | 2 +- .../proxyinitsink_fuzzer/initsink_fuzzer.cpp | 2 +- .../subscribelocalhardware_fuzzer.cpp | 2 +- .../unsubscribelocalhardware_fuzzer.cpp | 2 +- .../configdistributedhardware_fuzzer.cpp | 2 +- .../initsource_fuzzer.cpp | 2 +- .../registerdistributedhardware_fuzzer.cpp | 2 +- .../unregisterdistributedhardware_fuzzer.cpp | 2 +- .../configdistributedhardware_fuzzer.cpp | 2 +- .../initsource_fuzzer.cpp | 2 +- .../registerdistributedhardware_fuzzer.cpp | 2 +- .../unregisterdistributedhardware_fuzzer.cpp | 2 +- .../src/dscreen_source_handler_test.cpp | 18 +----------------- .../pluginhardware_fuzzer.cpp | 2 +- .../registerpluginlistener_fuzzer.cpp | 2 +- .../unpluginhardware_fuzzer.cpp | 2 +- .../src/screen_client_window_adapter.cpp | 4 ++-- services/screendemo/decoder_demo.cpp | 2 +- services/screendemo/test.cpp | 9 +++------ .../src/screen_data_channel_impl.cpp | 9 +++------ .../src/image_sink_processor.cpp | 4 ---- .../screensinktrans/src/screen_sink_trans.cpp | 11 ++--------- .../encoder/src/image_source_encoder.cpp | 5 +---- .../src/image_source_processor.cpp | 4 ---- .../src/screen_source_trans.cpp | 11 ++--------- 27 files changed, 32 insertions(+), 79 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp index b5acae69..eb9a523b 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/initsink_fuzzer.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { void InitSinkFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp index e6b49992..6d55f224 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp index cdeecb14..942ca8b1 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { void UnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp index df1d4c35..5c4c7c4a 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/initsink_fuzzer.cpp @@ -27,7 +27,7 @@ namespace OHOS { namespace DistributedHardware { void InitSinkFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp index c0dcb6d4..8dac4383 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp @@ -27,7 +27,7 @@ namespace OHOS { namespace DistributedHardware { void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp index 6d0596f2..7c39d54c 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp @@ -27,7 +27,7 @@ namespace OHOS { namespace DistributedHardware { void UnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp index cf1238d0..e6fdf7ab 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp index 4d804239..6868e7f9 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { void InitSourceFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp index 1ce18dca..aa347378 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp @@ -25,7 +25,7 @@ namespace OHOS { namespace DistributedHardware { void RegisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp index 6a36a164..7612e70b 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp @@ -25,7 +25,7 @@ namespace OHOS { namespace DistributedHardware { void UnregisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp index dca97995..a097bafb 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp @@ -27,7 +27,7 @@ namespace OHOS { namespace DistributedHardware { void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp index 01f5e3ef..aaa4ae91 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp @@ -28,7 +28,7 @@ namespace OHOS { namespace DistributedHardware { void InitSourceFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp index 0ce21584..82e40466 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp @@ -28,7 +28,7 @@ namespace OHOS { namespace DistributedHardware { void RegisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp index 9dbf372c..73357b41 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp @@ -28,7 +28,7 @@ namespace OHOS { namespace DistributedHardware { void UnregisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp index 3eb3ff72..86903c93 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp @@ -52,25 +52,9 @@ HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_001, TestSize.Lev std::shared_ptr callback = std::make_shared(); int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(DH_SUCCESS, ret); -} -/** - * @tc.name: RegisterDistributedHardware_002 - * @tc.desc: Verify the RegisterDistributedHardware function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_002, TestSize.Level1) -{ - const std::string devId = "devId"; - const std::string dhId = "dhId"; - EnableParam param; - param.version = "1"; - param.attrs = "attrs"; - std::shared_ptr callback = std::make_shared(); DScreenSourceHandler::GetInstance().dScreenSourceCallback_ = nullptr; - - int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); + ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT, ret); } diff --git a/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp index b5ee154d..dc8d2f23 100644 --- a/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp +++ b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { void PluginHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp index 7dc7ff40..b807086d 100644 --- a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp @@ -26,7 +26,7 @@ namespace OHOS { namespace DistributedHardware { void RegisterPluginListenerFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp index 1678eff2..3441383f 100644 --- a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp +++ b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { void UnPluginHardwareFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/services/screenclient/src/screen_client_window_adapter.cpp b/services/screenclient/src/screen_client_window_adapter.cpp index 8499d197..ef6279b9 100644 --- a/services/screenclient/src/screen_client_window_adapter.cpp +++ b/services/screenclient/src/screen_client_window_adapter.cpp @@ -107,7 +107,7 @@ int32_t ScreenClientWindowAdapter::ShowWindow(int32_t windowId) std::lock_guard dataLock(windowIdMapMutex_); auto iter = windowIdMap_.find(windowId); if (iter == windowIdMap_.end()) { - DHLOGE("ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR."); + DHLOGE("Invalid windowId (windowId = %d).", windowId); return ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR; } window = iter->second; @@ -131,7 +131,7 @@ int32_t ScreenClientWindowAdapter::HideWindow(int32_t windowId) std::lock_guard dataLock(windowIdMapMutex_); auto iter = windowIdMap_.find(windowId); if (iter == windowIdMap_.end()) { - DHLOGE("ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR."); + DHLOGE("Invalid windowId (windowId = %d).", windowId); return ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR; } window = iter->second; diff --git a/services/screendemo/decoder_demo.cpp b/services/screendemo/decoder_demo.cpp index b9e56ce5..23c597f3 100644 --- a/services/screendemo/decoder_demo.cpp +++ b/services/screendemo/decoder_demo.cpp @@ -243,7 +243,7 @@ void VDecDemo::InputFunc() uint32_t index = signal_->inQueue_.front(); auto buffer = vdec_->GetInputBuffer(index); - char *fileBuffer = (char *)malloc(sizeof(char) * (*frameLen) + 1); + char *fileBuffer = static_cast(malloc(sizeof(char) * (*frameLen) + 1)); if (fileBuffer == nullptr) { break; } diff --git a/services/screendemo/test.cpp b/services/screendemo/test.cpp index e915c9f4..762e5687 100644 --- a/services/screendemo/test.cpp +++ b/services/screendemo/test.cpp @@ -231,14 +231,14 @@ static void PrintNodeProperty(NodeBasicInfo *nodeInfo) if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, udid, UDID_BUF_LEN) != 0) { printf("GetNodeKeyInfo Fail!\n"); } else { - printf("Udid = %s\n", GetAnonyString((char *)udid).c_str()); + printf("Udid = %s\n", GetAnonyString(reinterpret_cast(udid)).c_str()); } key = NODE_KEY_UUID; unsigned char uuid[UUID_BUF_LEN] = {0}; if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, uuid, UUID_BUF_LEN) != 0) { printf("GetNodeKeyInfo Fail!\n"); } else { - printf("Uuid = %s\n", GetAnonyString((char *)uuid).c_str()); + printf("Uuid = %s\n", GetAnonyString(reinterpret_cast(udid)).c_str()); } } @@ -315,10 +315,7 @@ static void CreateWindow() cout << "create window success." << endl; auto vdec = make_shared(); - if (vdec == nullptr) { - cout << "videoDecoder is nullptr" << endl; - return; - } + vdec->SetWindowSize(windowWidth, windowHeight); vdec->SetOutputSurface(surface); cout << "start run decoder" << endl; diff --git a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp index b19f70b7..f9f94bfd 100644 --- a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp +++ b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp @@ -114,7 +114,7 @@ int32_t ScreenDataChannelImpl::SendData(const std::shared_ptr &scree return ERR_DH_SCREEN_TRANS_NULL_VALUE; } - StreamData data = {(char *)screenData->Data(), screenData->Capacity()}; + StreamData data = {reinterpret_cast(screenData->Data()), screenData->Capacity()}; StreamData ext = {0}; StreamFrameInfo frameInfo = {0}; @@ -183,12 +183,9 @@ void ScreenDataChannelImpl::OnStreamReceived(int32_t sessionId, const StreamData DHLOGI("%s: OnScreenStreamReceived, sessionId(%d) dataSize(%zu).", LOG_TAG, sessionId, data->bufLen); auto dataBuffer = std::make_shared(data->bufLen); - if (dataBuffer == nullptr) { - DHLOGE("%s: DataBuffer is null.", LOG_TAG); - return; - } - int32_t ret = memcpy_s(dataBuffer->Data(), dataBuffer->Capacity(), (uint8_t *)data->buf, data->bufLen); + int32_t ret = memcpy_s(dataBuffer->Data(), dataBuffer->Capacity(), reinterpret_cast(data->buf), + data->bufLen); if (ret != EOK) { DHLOGE("%s: Data memcpy_s failed.", LOG_TAG); return; diff --git a/services/screentransport/screensinkprocessor/src/image_sink_processor.cpp b/services/screentransport/screensinkprocessor/src/image_sink_processor.cpp index e692bff8..6cc0e46b 100644 --- a/services/screentransport/screensinkprocessor/src/image_sink_processor.cpp +++ b/services/screentransport/screensinkprocessor/src/image_sink_processor.cpp @@ -31,10 +31,6 @@ int32_t ImageSinkProcessor::ConfigureImageProcessor( remoteParam_ = remoteParam; imageDecoder_ = std::make_shared(imageListener); - if (imageDecoder_ == nullptr) { - DHLOGE("%s: Decoder is null.", LOG_TAG); - return ERR_DH_SCREEN_TRANS_NULL_VALUE; - } int32_t ret = imageDecoder_->ConfigureDecoder(localParam); if (ret != DH_SUCCESS) { diff --git a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp index 8b92aa29..f574ad10 100644 --- a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp +++ b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp @@ -208,10 +208,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid const std::string &peerDevId) { screenChannel_ = std::make_shared(peerDevId); - if (screenChannel_ == nullptr) { - DHLOGE("%s: Create screen data channel failed.", LOG_TAG); - return ERR_DH_SCREEN_TRANS_NULL_VALUE; - } + int32_t ret = RegisterChannelListener(); if (ret != DH_SUCCESS) { DHLOGE("%s: Register channel listener failed.", LOG_TAG); @@ -220,11 +217,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid } imageProcessor_ = std::make_shared(); - if (imageProcessor_ == nullptr) { - DHLOGE("%s: Create image processor failed.", LOG_TAG); - screenChannel_ = nullptr; - return ERR_DH_SCREEN_TRANS_NULL_VALUE; - } + ret = RegisterProcessorListener(localParam, remoteParam, peerDevId); if (ret != DH_SUCCESS) { DHLOGE("%s: Register processor listener failed.", LOG_TAG); diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index a265b8dc..f600a269 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -236,10 +236,7 @@ void ImageSourceEncoder::OnOutputBufferAvailable(uint32_t index, Media::AVCodecB return; } auto dataBuf = std::make_shared(dataSize); - if (dataBuf == nullptr) { - DHLOGE("%s: Create buffer failed.", LOG_TAG); - return; - } + int32_t ret = memcpy_s(dataBuf->Data(), dataBuf->Capacity(), videoSharedMemory_->GetBase(), dataSize); if (ret != EOK) { DHLOGE("%s: Copy data failed.", LOG_TAG); diff --git a/services/screentransport/screensourceprocessor/src/image_source_processor.cpp b/services/screentransport/screensourceprocessor/src/image_source_processor.cpp index 52cc5b52..077fb2f2 100644 --- a/services/screentransport/screensourceprocessor/src/image_source_processor.cpp +++ b/services/screentransport/screensourceprocessor/src/image_source_processor.cpp @@ -27,10 +27,6 @@ int32_t ImageSourceProcessor::ConfigureImageProcessor(const VideoParam &localPar { DHLOGI("%s: ConfigureImageProcessor.", LOG_TAG); imageEncoder_ = std::make_shared(listener); - if (imageEncoder_ == nullptr) { - DHLOGE("%s: Create screen encoder failed.", LOG_TAG); - return ERR_DH_SCREEN_TRANS_NULL_VALUE; - } int32_t ret = imageEncoder_->ConfigureEncoder(localParam); if (ret != DH_SUCCESS) { diff --git a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp index fc075ca9..b46522ea 100644 --- a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp +++ b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp @@ -226,10 +226,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V { DHLOGI("%s:InitScreenTrans.", LOG_TAG); screenChannel_ = std::make_shared(peerDevId); - if (screenChannel_ == nullptr) { - DHLOGE("%s: Create screen data channel failed.", LOG_TAG); - return ERR_DH_SCREEN_TRANS_NULL_VALUE; - } + int32_t ret = RegisterChannelListener(); if (ret != DH_SUCCESS) { DHLOGE("%s: Register channel listener failed ret: %d.", LOG_TAG, ret); @@ -238,11 +235,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V } imageProcessor_ = std::make_shared(); - if (imageProcessor_ == nullptr) { - DHLOGE("%s: Create image processor failed.", LOG_TAG); - screenChannel_ = nullptr; - return ERR_DH_SCREEN_TRANS_NULL_VALUE; - } + ret = RegisterProcessorListener(localParam, remoteParam); if (ret != DH_SUCCESS) { DHLOGE("%s: Register data processor listener failed ret: %d.", LOG_TAG, ret); -- Gitee