From: Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics
Date: Thu, 1 Feb 2024 13:05:00 +0000 (+0100)
Subject: [Alarm/BT/HAM/MediaCon/SysInfo] Fix Coverity issues
X-Git-Tag: accepted/tizen/unified/20240206.094545~1
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2921853ca0511978feafe947fb90c650f1620a09;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Alarm/BT/HAM/MediaCon/SysInfo] Fix Coverity issues
Issues:
1739921, 1741285, 1745119, 1746302, 1740124, 1740531, 1745380
[Verification] Auto TCT passed for modules Alarm, Bluetooth,
HumanactivityMonitor, Mediacontroller and Systeminfo
Change-Id: I05b09590936ceba63273bf92ad53577bb2a368fd
---
diff --git a/src/alarm/alarm_manager.cc b/src/alarm/alarm_manager.cc
index 4eae000f..19a3244d 100644
--- a/src/alarm/alarm_manager.cc
+++ b/src/alarm/alarm_manager.cc
@@ -369,7 +369,8 @@ void AlarmManager::AddAlarmNotification(const picojson::value& args, picojson::o
ret = alarm_schedule_noti_after_delay(notification_handle, delay, period, &alarm_id);
}
} else {
- if (alarm.find("period")->second.is()) {
+ const auto it_period = alarm.find("period");
+ if (alarm.end() != it_period && it_period->second.is()) {
LogAndReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR,
"AlarmAbsolute constructed by deprecated constructor."),
&out);
diff --git a/src/bluetooth/bluetooth_le_device.cc b/src/bluetooth/bluetooth_le_device.cc
index bb20d59d..20dc820c 100644
--- a/src/bluetooth/bluetooth_le_device.cc
+++ b/src/bluetooth/bluetooth_le_device.cc
@@ -484,7 +484,7 @@ void BluetoothLEDevice::GetAttMtu(const picojson::value& data, picojson::object&
const auto& address = common::FromJson(args, kAddress);
if (mac_address_.empty()) {
- mac_address_ == address;
+ mac_address_ = address;
}
bt_gatt_client_h client = service_.GetGattClientHandle(address);
@@ -512,7 +512,7 @@ void BluetoothLEDevice::RequestAttMtuChange(const picojson::value& data, picojso
const auto& address = common::FromJson(args, kAddress);
if (mac_address_.empty()) {
- mac_address_ == address;
+ mac_address_ = address;
}
bt_gatt_client_h client = service_.GetGattClientHandle(address);
@@ -535,7 +535,7 @@ void BluetoothLEDevice::AddAttMtuChangeListener(const picojson::value& data,
const auto& address = common::FromJson(args, kAddress);
if (mac_address_.empty()) {
- mac_address_ == address;
+ mac_address_ = address;
}
bt_gatt_client_h client = service_.GetGattClientHandle(address);
diff --git a/src/humanactivitymonitor/humanactivitymonitor_manager.cc b/src/humanactivitymonitor/humanactivitymonitor_manager.cc
index 3e54beec..67031e39 100644
--- a/src/humanactivitymonitor/humanactivitymonitor_manager.cc
+++ b/src/humanactivitymonitor/humanactivitymonitor_manager.cc
@@ -661,6 +661,7 @@ class HumanActivityMonitorManager::Monitor::SensorMonitor
void addRecordedData(picojson::value* data) {
ScopeLogger();
+ std::lock_guard lock(mutex_);
recorded_data_->push_back(*data);
}
diff --git a/src/mediacontroller/mediacontroller_server.cc b/src/mediacontroller/mediacontroller_server.cc
index 85b48e99..74f0fbbe 100644
--- a/src/mediacontroller/mediacontroller_server.cc
+++ b/src/mediacontroller/mediacontroller_server.cc
@@ -344,6 +344,7 @@ PlatformResult MediaControllerServer::SetMetadata(const picojson::object& metada
}
}
+ std::lock_guard lock(handle_mutex_);
int ret = mc_server_update_metadata(handle_);
if (MEDIA_CONTROLLER_ERROR_NONE != ret) {
return LogAndCreateResult(
diff --git a/src/systeminfo/systeminfo_sim_details_manager.cc b/src/systeminfo/systeminfo_sim_details_manager.cc
index 8b85d5b2..f1c758ec 100644
--- a/src/systeminfo/systeminfo_sim_details_manager.cc
+++ b/src/systeminfo/systeminfo_sim_details_manager.cc
@@ -147,10 +147,11 @@ PlatformResult SimDetailsManager::GatherSimInformation(TapiHandle* handle, picoj
return ret;
}
// The variable used to determine if double mutex-locking is needed.
- auto to_process_cached = to_process_;
+ unsigned short to_process_cached = 0;
{
// All props should be fetched synchronously, but sync function does not work
std::lock_guard lock_to_process(sim_to_process_mutex_);
+ to_process_cached = to_process_;
// would be deleted on } ending bracket
int result = tel_get_sim_cphs_netname(handle, SimCphsValueCallback, this);
if (TAPI_API_SUCCESS == result) {