diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 8f4472cc86dbe81d3017d4c9235957fd3d9e33f3..d9f41df36ae86ba0985ce408c5deec84bbe81602 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -30,7 +30,7 @@ DScreenSinkHandler::DScreenSinkHandler() { DHLOGI("DScreenSinkHandler construct."); std::lock_guard lock(mutex_); - if (!sinkSvrRecipient_) { + if (sinkSvrRecipient_ == nullptr) { sinkSvrRecipient_ = new DScreenSinkSvrRecipient(); } } @@ -45,22 +45,22 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) DHLOGD("InitSink"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (!samgr) { + if (samgr == nullptr) { DHLOGE("Failed to get system ability mgr."); return ERR_DH_SCREEN_SA_GET_SAMGR_FAIL; } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); - if (!remoteObject) { + if (remoteObject == nullptr) { DHLOGE("Failed to get dscreen sink service."); return ERR_DH_SCREEN_SA_GET_SINKSERVICE_FAIL; } remoteObject->AddDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = iface_cast(remoteObject); - if ((!dScreenSinkProxy_) || (!dScreenSinkProxy_->AsObject())) { + if ((dScreenSinkProxy_== nullptr) || (dScreenSinkProxy_->AsObject() == nullptr)) { DHLOGE("Failed to get dscreen sink proxy."); return ERR_DH_SCREEN_SA_GET_SINKPROXY_FAIL; } @@ -73,7 +73,7 @@ int32_t DScreenSinkHandler::ReleaseSink() { DHLOGD("ReleaseSink"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; } @@ -86,7 +86,7 @@ int32_t DScreenSinkHandler::SubscribeLocalHardware(const std::string &dhId, cons { DHLOGD("SubscribeLocalHardware"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; } @@ -98,7 +98,7 @@ int32_t DScreenSinkHandler::UnsubscribeLocalHardware(const std::string &dhId) { DHLOGD("UnsubscribeLocalHardware"); std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; } @@ -116,12 +116,12 @@ void DScreenSinkHandler::OnRemoteSinkSvrDied(const wptr &remote) { DHLOGI("OnRemoteSinkSvrDied"); sptr remoteObject = remote.promote(); - if (!remoteObject) { + if (remoteObject == nullptr) { DHLOGE("OnRemoteDied remote promoted failed"); return; } std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ == nullptr) { dScreenSinkProxy_->AsObject()->RemoveDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = nullptr; } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index ed5e3c0f89c79b46a453b839d4241335ae20c355..a24a8e58ea19c3bb8ed6a852abecc0c49bdf2e80 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -31,11 +31,11 @@ DScreenSourceHandler::DScreenSourceHandler() { DHLOGI("DScreenSourceHandler construct."); std::lock_guard lock(mutex_); - if (!sourceSvrRecipient_) { + if (sourceSvrRecipient_ == nullptr) { sourceSvrRecipient_ = new DScreenSourceSvrRecipient(); } - if (!dScreenSourceCallback_) { + if (dScreenSourceCallback_ == nullptr) { dScreenSourceCallback_ = new DScreenSourceCallback(); } } @@ -50,22 +50,22 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) DHLOGD("InitSource"); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (!samgr) { + if (samgr == nullptr) { DHLOGE("Failed to get system ability mgr."); return ERR_DH_SCREEN_SA_GET_SAMGR_FAIL; } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); - if (!remoteObject) { + if (remoteObject == nullptr) { DHLOGE("Failed to get dscreen source service."); return ERR_DH_SCREEN_SA_GET_SOURCESERVICE_FAIL; } remoteObject->AddDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = iface_cast(remoteObject); - if ((!dScreenSourceProxy_) || (!dScreenSourceProxy_->AsObject())) { + if ((dScreenSourceProxy_ == nullptr) || (dScreenSourceProxy_->AsObject() == nullptr)) { DHLOGE("Failed to get dscreen source proxy."); return ERR_DH_SCREEN_SA_GET_SOURCEPROXY_FAIL; } @@ -79,7 +79,7 @@ int32_t DScreenSourceHandler::ReleaseSource() { DHLOGD("ReleaseSource"); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } @@ -93,11 +93,11 @@ int32_t DScreenSourceHandler::RegisterDistributedHardware(const std::string &dev DHLOGD("RegisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } - if (!dScreenSourceCallback_) { + if (dScreenSourceCallback_ == nullptr) { DHLOGE("screen source callback is null."); return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; } @@ -114,11 +114,11 @@ int32_t DScreenSourceHandler::UnregisterDistributedHardware(const std::string &d DHLOGD("UnregisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } - if (!dScreenSourceCallback_) { + if (dScreenSourceCallback_ == nullptr) { DHLOGE("screen source callback is null."); return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; } @@ -146,12 +146,12 @@ void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remo { DHLOGI("OnRemoteSourceSvrDied"); sptr remoteObject = remote.promote(); - if (!remoteObject) { + if (remoteObject == nullptr) { DHLOGE("OnRemoteDied remote promoted failed"); return; } std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { + if (dScreenSourceProxy_ == nullptr) { dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = nullptr; } diff --git a/screenhandler/src/dscreen_handler.cpp b/screenhandler/src/dscreen_handler.cpp index e6f4f589e2a1a94f3fcf7e02b51df50a41ea6273..c6dd255c79167f78f8029bcdd60f94955d5740bf 100644 --- a/screenhandler/src/dscreen_handler.cpp +++ b/screenhandler/src/dscreen_handler.cpp @@ -45,7 +45,7 @@ DScreenHandler::~DScreenHandler() int32_t DScreenHandler::Initialize() { DHLOGI("DScreenHandler Initialize"); - if (!screenListener_) { + if (screenListener_ == nullptr) { screenListener_ = new ScreenListener(); } bool ret = Rosen::ScreenManager::GetInstance().RegisterScreenListener(screenListener_); diff --git a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp index 9fdf73b13ddc1d91c21ed0ffaf6ef88eee83c99f..8abbf3f3b4c6b8156ba01305f3bbd6ac86bf27ae 100644 --- a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp @@ -37,7 +37,7 @@ ScreenRegion::ScreenRegion(const std::string &remoteDevId, uint64_t screenId, ui ScreenRegion::~ScreenRegion() { DHLOGD("ScreenRegion deConstruct"); - if (!sinkTrans_) { + if (sinkTrans_ != nullptr) { sinkTrans_->Release(); } } @@ -78,6 +78,10 @@ int32_t ScreenRegion::SetUp() DHLOGI("ScreenRegion::SetUp, remoteDevId: %s", GetAnonyString(remoteDevId_).c_str()); std::shared_ptr windowProperty = std::make_shared(); + if (windowProperty == nullptr) { + DHLOGE("windowProperty is nullptr."); + return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; + } windowProperty->displayId = displayId_; ScreenRect screenRect = mapRelation_->GetScreenRect(); @@ -97,15 +101,15 @@ int32_t ScreenRegion::SetUp() return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; } - sptr surface = ScreenClient::GetInstance().GetSurface(windowId_); - if (!surface) { - DHLOGE("get window surface failed."); + sptr screenSurface = ScreenClient::GetInstance().GetSurface(windowId_); + if (screenSurface == nullptr) { + DHLOGE("get window screenSurface failed."); return ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED; } - surface_ = surface; + surface_ = screenSurface; - if (!sinkTrans_) { + if (sinkTrans_ == nullptr) { sinkTrans_ = std::make_shared(); } @@ -123,7 +127,7 @@ int32_t ScreenRegion::SetUp() int32_t ScreenRegion::Start() { DHLOGI("ScreenRegion::Start remoteDevId: %s", GetAnonyString(remoteDevId_).c_str()); - if (!sinkTrans_) { + if (sinkTrans_ == nullptr) { DHLOGE("sink trans not init."); return ERR_DH_SCREEN_SA_SINKTRANS_NOT_INIT; } @@ -145,7 +149,7 @@ int32_t ScreenRegion::Stop() return DH_SUCCESS; } - if (!sinkTrans_) { + if (sinkTrans_ == nullptr) { DHLOGE("sink trans not init."); return ERR_DH_SCREEN_SA_SINKTRANS_NOT_INIT; } diff --git a/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp b/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp index 48457eeb65876894c1f35366eff3db4bc7e15a21..679470b34a7bc211010d08db8a629653185219c6 100644 --- a/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/src/screenregionmgr.cpp @@ -50,7 +50,7 @@ int32_t ScreenRegionManager::ReleaseAllRegions() std::lock_guard lock(screenRegionsMtx_); for (const auto &item : screenRegions_) { std::shared_ptr screenRegion = item.second; - if (!screenRegion) { + if (screenRegion == nullptr) { continue; } int32_t ret = screenRegion->Stop(); @@ -100,6 +100,10 @@ void ScreenRegionManager::HandleNotifySetUp(const std::string &remoteDevId, cons uint64_t displayId = Rosen::DisplayManager::GetInstance().GetDefaultDisplayId(); std::shared_ptr screenRegion = std::make_shared(remoteDevId, screenId, displayId); + if (screenRegion == nullptr || videoParam == nullptr || mapRelation == nullptr) { + NotifyRemoteSourceSetUpResult(remoteDevId, dhId, ERR_DH_SCREEN_SA_SCREENREGION_SETUP_FAIL, ""); + return; + } screenRegion->SetVideoParam(videoParam); screenRegion->SetMapRelation(mapRelation); @@ -159,7 +163,7 @@ int32_t ScreenRegionManager::NotifyRemoteScreenService(const std::string &remote DHLOGI("Notify remote source screen service, remote devId: %s, eventCode: %d", GetAnonyString(remoteDevId).c_str(), eventCode); sptr remoteSourceSA = GetDScreenSourceSA(remoteDevId); - if (!remoteSourceSA) { + if (remoteSourceSA == nullptr) { DHLOGE("get remote source sa failed."); return ERR_DH_SCREEN_SA_GET_REMOTE_SOURCE_SERVICE_FAIL; } diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp index d6e73fdbbbe5acd7a50999de017b9dede06e7f7c..d7a90bf371005dfceb91a9d32ae151f2110dd7cc 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp @@ -50,7 +50,7 @@ DScreen::~DScreen() taskQueueThread_.join(); } int32_t ret = DH_SUCCESS; - if (sourceTrans_) { + if (sourceTrans_ != nullptr) { ret = sourceTrans_->Release(); } if (ret != DH_SUCCESS) { @@ -116,7 +116,7 @@ int32_t DScreen::AddTask(const std::shared_ptr &task) { DHLOGI("DScreen::AddTask, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!task) { + if (task == nullptr) { DHLOGE("AddTask, task is invalid."); return ERR_DH_SCREEN_SA_DSCREEN_TASK_NOT_VALID; } @@ -189,7 +189,7 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) } SetState(ENABLING); - if (!videoParam_) { + if (videoParam_ == nullptr) { videoParam_ = std::make_shared(); } @@ -337,7 +337,7 @@ int32_t DScreen::SetUp() DHLOGD("SetUp, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!sourceTrans_) { + if (sourceTrans_ == nullptr) { sourceTrans_ = std::make_shared(); } @@ -359,7 +359,7 @@ int32_t DScreen::Start() { DHLOGD("Start, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!sourceTrans_) { + if (sourceTrans_ == nullptr) { DHLOGE("source trans not init."); return ERR_DH_SCREEN_SA_SOURCETRANS_NOT_INIT; } @@ -376,7 +376,7 @@ int32_t DScreen::Stop() { DHLOGD("Stop, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); - if (!sourceTrans_) { + if (sourceTrans_ == nullptr) { DHLOGE("source trans not init."); return ERR_DH_SCREEN_SA_SOURCETRANS_NOT_INIT; } diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp index 1b5ceb49c69904f2db1958330fbeaed9c9132c8c..374a3de1a58ea7b587e0ad715fa9dfe8532edfb1 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp @@ -51,7 +51,7 @@ int32_t DScreenManager::Init() if (ret != DH_SUCCESS) { DHLOGE("DScreenManager Init failed, err: %d", ret); } - if (!dScreenCallback_) { + if (dScreenCallback_ == nullptr) { dScreenCallback_ = std::make_shared(); } return ret; @@ -91,7 +91,7 @@ void DScreenGroupListener::OnChange(const std::vector &screenIds, Rose for (uint64_t screenId : screenIds) { std::shared_ptr changedScreen = nullptr; changedScreen = DScreenManager::GetInstance().FindDScreenByScreenId(screenId); - if (!changedScreen) { + if (changedScreen == nullptr) { DHLOGD("screen change not about remote screen, screenId: %ulld", screenId); continue; } @@ -102,7 +102,7 @@ void DScreenGroupListener::OnChange(const std::vector &screenIds, Rose void DScreenManager::HandleScreenChange(const std::shared_ptr &changedScreen, Rosen::ScreenGroupChangeEvent event) { - if (!changedScreen) { + if (changedScreen == nullptr) { DHLOGE("DScreenManager::HandleScreenChange, dScreen is null."); return; } @@ -175,7 +175,7 @@ void DScreenManager::OnRegResult(const std::shared_ptr &dScreen, { DHLOGI("DScreenManager::OnRegResult, devId: %s, dhId: %s, reqId: %s", GetAnonyString(dScreen->GetDevId()).c_str(), GetAnonyString(dScreen->GetDHId()).c_str(), reqId.c_str()); - if (!dScreenSourceCallbackProxy_) { + if (dScreenSourceCallbackProxy_ == nullptr) { DHLOGE("dScreenSourceCallbackProxy is null"); return; } @@ -187,7 +187,7 @@ void DScreenManager::OnUnregResult(const std::shared_ptr &dScreen, { DHLOGI("DScreenManager::OnUnregResult, devId: %s, dhId: %s, reqId: %s", GetAnonyString(dScreen->GetDevId()).c_str(), GetAnonyString(dScreen->GetDHId()).c_str(), reqId.c_str()); - if (!dScreenSourceCallbackProxy_) { + if (dScreenSourceCallbackProxy_ == nullptr) { DHLOGE("dScreenSourceCallbackProxy is null"); return; } @@ -276,7 +276,7 @@ std::shared_ptr DScreenManager::FindDScreenByScreenId(uint64_t screenId std::lock_guard lock(dScreenMapMtx_); for (const auto &iter : dScreens_) { std::shared_ptr dScreen = iter.second; - if (!dScreen) { + if (dScreen == nullptr) { continue; } @@ -306,7 +306,7 @@ int32_t DScreenManager::NotifyRemoteScreenService(const std::string &devId, int3 DHLOGI("Notify remote sink screen service, remote devId: %s, eventCode: %d", GetAnonyString(devId).c_str(), eventCode); sptr remoteSinkSA = GetDScreenSinkSA(devId); - if (!remoteSinkSA) { + if (remoteSinkSA == nullptr) { DHLOGE("get remote sink sa failed."); return ERR_DH_SCREEN_SA_GET_REMOTE_SINK_SERVICE_FAIL; } @@ -325,7 +325,7 @@ sptr DScreenManager::GetDScreenSinkSA(const std::string &devId) DHLOGI("GetDScreenSinkSA, devId: %s", GetAnonyString(devId).c_str()); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (!samgr) { + if (samgr == nullptr) { DHLOGE("Failed to get system ability mgr."); return nullptr; } diff --git a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp index 4f0850bfb97257fef19a0b4a726e083042500a05..ed59bb1d17f8eb44750ac8bb3a61fdd09662ed0a 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp @@ -115,6 +115,10 @@ std::shared_ptr ScreenMgrAdapter::GetMapRelation(uint64_t sc { DHLOGI("GetMapRelation"); std::shared_ptr mapRelation = std::make_shared(); + if (mapRelation == nullptr) { + DHLOGE("mapRelation is nullptr."); + return nullptr; + } sptr screen = Rosen::ScreenManager::GetInstance().GetScreenById(screenId); sptr display = Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); mapRelation->SetDisplayId(display->GetId()); diff --git a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp index 6097c4a5c64a91659f96305bb884e29a6632358e..a6d46d95b1694d0d34ac62342b2718541492b484 100644 --- a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp +++ b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp @@ -27,7 +27,7 @@ namespace DistributedHardware { int32_t ScreenDataChannelImpl::CreateSession(const std::shared_ptr &listener) { DHLOGI("%s: CreateSession, peerDevId(%s)", LOG_TAG, GetAnonyString(peerDevId_).c_str()); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -107,7 +107,7 @@ int32_t ScreenDataChannelImpl::CloseSession() int32_t ScreenDataChannelImpl::SendData(const std::shared_ptr &screenData) { DHLOGD("%s: SendData, sessionId(%d)", LOG_TAG, sessionId_); - if (!screenData) { + if (screenData == nullptr) { DHLOGE("%s: Screen data is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -134,7 +134,7 @@ void ScreenDataChannelImpl::OnSessionOpened(int32_t sessionId, int32_t result) } std::shared_ptr listener = channelListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return; } @@ -146,7 +146,7 @@ void ScreenDataChannelImpl::OnSessionClosed(int32_t sessionId) { DHLOGI("%s: OnScreenSessionClosed, sessionId(%d).", LOG_TAG, sessionId); std::shared_ptr listener = channelListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return; } @@ -174,14 +174,14 @@ void ScreenDataChannelImpl::OnStreamReceived(int32_t sessionId, const StreamData } std::shared_ptr listener = channelListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null.", LOG_TAG); return; } DHLOGI("%s: OnScreenStreamReceived, sessionId(%d) dataSize(%zu).", LOG_TAG, sessionId, data->bufLen); auto dataBuffer = std::make_shared(data->bufLen); - if (!dataBuffer) { + if (dataBuffer == nullptr) { DHLOGE("%s: DataBuffer is null.", LOG_TAG); return; } diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index a210198fe81a49f336b7f99b462c9620cf13ff2e..495c3dae758bc5e7ad18554003a0fd34a37d356a 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -45,7 +45,7 @@ int32_t ImageSinkDecoder::ConfigureDecoder(const VideoParam &configParam) int32_t ImageSinkDecoder::ReleaseDecoder() { DHLOGI("%s: ReleaseDecoder.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -64,7 +64,7 @@ int32_t ImageSinkDecoder::ReleaseDecoder() int32_t ImageSinkDecoder::StartDecoder() { DHLOGI("%s: StartDecoder.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -88,7 +88,7 @@ int32_t ImageSinkDecoder::StartDecoder() int32_t ImageSinkDecoder::StopDecoder() { DHLOGI("%s: StopDecoder.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -145,7 +145,7 @@ int32_t ImageSinkDecoder::InitVideoDecoder(const VideoParam &configParam) int32_t ImageSinkDecoder::SetDecoderFormat(const VideoParam &configParam) { DHLOGI("%s: SetDecoderFormat.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -199,7 +199,7 @@ int32_t ImageSinkDecoder::SetDecoderFormat(const VideoParam &configParam) int32_t ImageSinkDecoder::SetOutputSurface(sptr &surface) { DHLOGI("%s: SetOutputSurface.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -231,7 +231,7 @@ void ImageSinkDecoder::OnError(Media::AVCodecErrorType errorType, int32_t errorC { DHLOGI("%s: OnImageDecodeError, errorType(%d), errorCode(%d)", LOG_TAG, errorType, errorCode); std::shared_ptr listener = imageProcessorListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Listener is null.", LOG_TAG); return; } @@ -249,7 +249,7 @@ void ImageSinkDecoder::OnOutputBufferAvailable(uint32_t index, Media::AVCodecBuf Media::AVCodecBufferFlag flag) { DHLOGI("%s: OnDecodeOutputBufferAvailable.", LOG_TAG); - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return; } @@ -322,7 +322,7 @@ void ImageSinkDecoder::DecodeScreenData() int32_t ImageSinkDecoder::ProcessData(const std::shared_ptr &screenData, const int32_t bufferIndex) { - if (!videoDecoder_) { + if (videoDecoder_ == nullptr) { DHLOGE("%s: Decoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } diff --git a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp index 6de90dc2c5f1f87e14cabd89ecf6c5e7591e5b7a..462c4b9df0a56573c5aa4d3c00f999e6ed4acc2d 100644 --- a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp +++ b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp @@ -45,8 +45,8 @@ int32_t ScreenSinkTrans::SetUp(const VideoParam &localParam, const VideoParam &r int32_t ScreenSinkTrans::Release() { DHLOGI("%s: Release.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Release failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -69,8 +69,8 @@ int32_t ScreenSinkTrans::Release() int32_t ScreenSinkTrans::Start() { DHLOGI("%s: Start.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Start failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -87,8 +87,8 @@ int32_t ScreenSinkTrans::Start() int32_t ScreenSinkTrans::Stop() { DHLOGI("%s: Stop.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Stop failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -117,7 +117,7 @@ int32_t ScreenSinkTrans::Stop() int32_t ScreenSinkTrans::RegisterStateCallback(const std::shared_ptr &callback) { DHLOGI("%s:RegisterStateCallback.", LOG_TAG); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -128,7 +128,7 @@ int32_t ScreenSinkTrans::RegisterStateCallback(const std::shared_ptr &surface) { - if (!surface) { + if (surface == nullptr) { DHLOGE("%s: Image surface is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -202,7 +202,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid const std::string &peerDevId) { screenChannel_ = std::make_shared(peerDevId); - if (!screenChannel_) { + if (screenChannel_ == nullptr) { DHLOGE("%s: Create screen data channel failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -214,7 +214,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid } imageProcessor_ = std::make_shared(); - if (!imageProcessor_) { + if (imageProcessor_ == nullptr) { DHLOGE("%s: Create image processor failed.", LOG_TAG); screenChannel_ = nullptr; return ERR_DH_SCREEN_TRANS_NULL_VALUE; @@ -234,7 +234,7 @@ int32_t ScreenSinkTrans::RegisterChannelListener() { DHLOGI("%s: RegisterChannelListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel Listener is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -253,7 +253,7 @@ int32_t ScreenSinkTrans::RegisterProcessorListener(const VideoParam &localParam, { DHLOGI("%s: RegisterProcessorListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener to null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -281,7 +281,7 @@ void ScreenSinkTrans::OnSessionClosed() { DHLOGI("%s:OnChannelSessionClosed.", LOG_TAG); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } @@ -301,7 +301,7 @@ void ScreenSinkTrans::OnProcessorStateNotify(int32_t state) { DHLOGI("%s: OnProcessorStateNotify.", LOG_TAG); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index bb8f216d71721b165bccbdb809716e09b742eb16..0f0dc3821ed078c1436e6248a8ce89f5305cb96f 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -51,7 +51,7 @@ int32_t ImageSourceEncoder::ConfigureEncoder(const VideoParam &configParam) int32_t ImageSourceEncoder::ReleaseEncoder() { DHLOGI("%s: ReleaseEncoder.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -70,7 +70,7 @@ int32_t ImageSourceEncoder::ReleaseEncoder() int32_t ImageSourceEncoder::StartEncoder() { DHLOGI("%s: StartEncoder.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -93,7 +93,7 @@ int32_t ImageSourceEncoder::StartEncoder() int32_t ImageSourceEncoder::StopEncoder() { DHLOGI("%s: StopEncoder.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -148,7 +148,7 @@ int32_t ImageSourceEncoder::InitVideoEncoder(const VideoParam &configParam) int32_t ImageSourceEncoder::SetEncoderFormat(const VideoParam &configParam) { DHLOGI("%s: SetEncoderFormat.", LOG_TAG); - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -201,7 +201,7 @@ void ImageSourceEncoder::OnError(Media::AVCodecErrorType errorType, int32_t erro { DHLOGI("%s: Encoder error, errorType(%d), errorCode(%d)", LOG_TAG, errorType, errorCode); std::shared_ptr listener = imageProcessorListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Processor listener is null", LOG_TAG); return; } @@ -213,25 +213,25 @@ void ImageSourceEncoder::OnOutputBufferAvailable(uint32_t index, Media::AVCodecB { DHLOGD("%s: OnOutputBufferAvailable.", LOG_TAG); std::shared_ptr listener = imageProcessorListener_.lock(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Processor listener is null", LOG_TAG); return; } - if (!videoEncoder_) { + if (videoEncoder_ == nullptr) { DHLOGE("%s: Encoder is null.", LOG_TAG); return; } encoderBufferInfo_ = info; videoSharedMemory_ = videoEncoder_->GetOutputBuffer(index); - if (!videoSharedMemory_) { + if (videoSharedMemory_ == nullptr) { DHLOGE("%s: GetOutputBuffer failed.", LOG_TAG); return; } size_t dataSize = static_cast(info.size); auto dataBuf = std::make_shared(dataSize); - if (!dataBuf) { + if (dataBuf == nullptr) { DHLOGE("%s: Create buffer failed.", LOG_TAG); return; } diff --git a/services/screentransport/screensourceprocessor/src/image_source_processor.cpp b/services/screentransport/screensourceprocessor/src/image_source_processor.cpp index 68e74783291262b99dff9699473f152d242cb0d2..840d30aa827675650481305f41462b42f65b9878 100644 --- a/services/screentransport/screensourceprocessor/src/image_source_processor.cpp +++ b/services/screentransport/screensourceprocessor/src/image_source_processor.cpp @@ -25,7 +25,7 @@ int32_t ImageSourceProcessor::ConfigureImageProcessor(const VideoParam &localPar { DHLOGI("%s: ConfigureImageProcessor.", LOG_TAG); imageEncoder_ = std::make_shared(listener); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -44,7 +44,7 @@ int32_t ImageSourceProcessor::ConfigureImageProcessor(const VideoParam &localPar int32_t ImageSourceProcessor::ReleaseImageProcessor() { DHLOGI("%s: ReleaseImageProcessor.", LOG_TAG); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -61,7 +61,7 @@ int32_t ImageSourceProcessor::ReleaseImageProcessor() int32_t ImageSourceProcessor::StartImageProcessor() { DHLOGI("%s: StartImageProcessor.", LOG_TAG); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -78,7 +78,7 @@ int32_t ImageSourceProcessor::StartImageProcessor() int32_t ImageSourceProcessor::StopImageProcessor() { DHLOGI("%s: StopImageProcessor.", LOG_TAG); - if (!imageEncoder_) { + if (imageEncoder_ == nullptr) { DHLOGE("%s: Create screen encoder failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } diff --git a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp index 6d2ef574b8f5b7ba7ce236ffcb639be1c1e0da7f..11d46cafa19d47f6d2b41b7616486ce31e92480b 100644 --- a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp +++ b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp @@ -47,8 +47,8 @@ int32_t ScreenSourceTrans::SetUp(const VideoParam &localParam, const VideoParam int32_t ScreenSourceTrans::Release() { DHLOGI("%s: Release.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Release failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -76,8 +76,8 @@ int32_t ScreenSourceTrans::Release() int32_t ScreenSourceTrans::Start() { DHLOGI("%s: Start.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Start failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -103,8 +103,8 @@ int32_t ScreenSourceTrans::Start() int32_t ScreenSourceTrans::Stop() { DHLOGI("%s: Stop.", LOG_TAG); - if (!imageProcessor_ || !screenChannel_) { - DHLOGE("%s: Processor or channel is null, Setup first.", LOG_TAG); + if (imageProcessor_ == nullptr || screenChannel_ == nullptr) { + DHLOGE("%s: Processor or channel is null, Stop failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -134,7 +134,7 @@ int32_t ScreenSourceTrans::Stop() int32_t ScreenSourceTrans::RegisterStateCallback(const std::shared_ptr &callback) { DHLOGI("%s:RegisterStateCallback.", LOG_TAG); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -214,7 +214,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V const std::string &peerDevId) { screenChannel_ = std::make_shared(peerDevId); - if (!screenChannel_) { + if (screenChannel_ == nullptr) { DHLOGE("%s: Create screen data channel failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -226,7 +226,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V } imageProcessor_ = std::make_shared(); - if (!imageProcessor_) { + if (imageProcessor_ == nullptr) { DHLOGE("%s: Create image processor failed.", LOG_TAG); screenChannel_ = nullptr; return ERR_DH_SCREEN_TRANS_NULL_VALUE; @@ -246,7 +246,7 @@ int32_t ScreenSourceTrans::RegisterChannelListener() { DHLOGI("%s: RegisterChannelListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Channel listener is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -268,7 +268,7 @@ int32_t ScreenSourceTrans::RegisterProcessorListener(const VideoParam &localPara { DHLOGI("%s: RegisterProcessorListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); - if (!listener) { + if (listener == nullptr) { DHLOGE("%s: Processor listener is null", LOG_TAG); return ERR_DH_SCREEN_TRANS_ERROR; } @@ -280,7 +280,7 @@ int32_t ScreenSourceTrans::RegisterProcessorListener(const VideoParam &localPara } encoderSurface_ = imageProcessor_->GetImageSurface(); - if (!encoderSurface_) { + if (encoderSurface_ == nullptr) { DHLOGE("%s: Surface is null.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } @@ -312,7 +312,7 @@ void ScreenSourceTrans::OnSessionClosed() sendDataThread_.join(); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } @@ -341,7 +341,7 @@ void ScreenSourceTrans::OnProcessorStateNotify(int32_t state) { DHLOGI("%s:OnProcessorStateNotify.", LOG_TAG); std::shared_ptr callback = transCallback_.lock(); - if (!callback) { + if (callback == nullptr) { DHLOGE("%s: Trans callback is null.", LOG_TAG); return; } diff --git a/services/softbusadapter/src/softbus_adapter.cpp b/services/softbusadapter/src/softbus_adapter.cpp index 540590b01a1d578df6bcfdaed850ec22c264ba1f..9b7ceed4a4b7c30df2278f7bbee7d46dc4d3e30d 100644 --- a/services/softbusadapter/src/softbus_adapter.cpp +++ b/services/softbusadapter/src/softbus_adapter.cpp @@ -264,7 +264,7 @@ int32_t SoftbusAdapter::OnSoftbusSessionOpened(int32_t sessionId, int32_t result } std::shared_ptr &listener = GetSoftbusListenerByName(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return ERR_DH_SCREEN_TRANS_ERROR; } @@ -280,7 +280,7 @@ void SoftbusAdapter::OnSoftbusSessionClosed(int32_t sessionId) { DHLOGI("%s: OnSessionClosed sessionId:%d.", LOG_TAG, sessionId); std::shared_ptr &listener = GetSoftbusListenerById(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return; } @@ -303,7 +303,7 @@ void SoftbusAdapter::OnBytesReceived(int32_t sessionId, const void *data, uint32 } std::shared_ptr &listener = GetSoftbusListenerByName(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return; } @@ -324,7 +324,7 @@ void SoftbusAdapter::OnStreamReceived(int32_t sessionId, const StreamData *data, } std::shared_ptr &listener = GetSoftbusListenerByName(sessionId); - if (!listener) { + if (listener == nullptr) { DHLOGE("Get softbus listener failed."); return; }