diff options
author | saerome.kim <saerome.kim@samsung.com> | 2019-08-26 17:57:21 +0900 |
---|---|---|
committer | saerome.kim <saerome.kim@samsung.com> | 2019-08-26 20:00:23 +0900 |
commit | 5324a11e7b2da759fee3d933d9c5ec16f6d3eefe (patch) | |
tree | f3c5b653207e05a5a96c170d7e54c85a810fe412 | |
parent | f4f275dba6fb017771001c3e500ca8bc30198075 (diff) | |
download | user-awareness-5324a11e7b2da759fee3d933d9c5ec16f6d3eefe.tar.gz user-awareness-5324a11e7b2da759fee3d933d9c5ec16f6d3eefe.tar.bz2 user-awareness-5324a11e7b2da759fee3d933d9c5ec16f6d3eefe.zip |
Fixed the Coverity & Svace issues.
1078724 Leaked_storage: Variable mac going out of scope leaks the storage it points to.
1078723 copy_paste_error: g_presence_and_cond looks like a copy-paste error.
1078720 Check return: Calling ua_device_get_mac_address without checking return value.
1078717 Check_return:Calling ua_device_get_mac_type without checking return value.
1076181 Leaked_storage: Variable service going out of scope leaks the storage it points to.
1076152 Leaked_storage: Variable service going out of scope leaks the storage it points to.
405915 Leaked_storage: Variable mac going out of scope leaks the storage it points to
Change-Id: I1c8d80568c0df9901abcdc0c26a5318b7faa3a6b
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
-rw-r--r-- | packaging/capi-network-ua.spec | 2 | ||||
-rw-r--r-- | src/user-awareness-monitors.c | 8 | ||||
-rw-r--r-- | test/uat-detections.c | 4 | ||||
-rw-r--r-- | test/uat-init.c | 26 |
4 files changed, 30 insertions, 10 deletions
diff --git a/packaging/capi-network-ua.spec b/packaging/capi-network-ua.spec index 8edc80e..47b1e11 100644 --- a/packaging/capi-network-ua.spec +++ b/packaging/capi-network-ua.spec @@ -1,6 +1,6 @@ Name: capi-network-ua Summary: User Awareness Framework CAPI -Version: 0.6.9 +Version: 0.6.10 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index 7e9dd35..5a0b317 100644 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -698,6 +698,8 @@ int ua_monitor_start_presence_detection( monitor->user_data = user_data; monitor->presence_detection_started = TRUE; + g_free(service); + FUNC_EXIT; return UA_ERROR_NONE; } @@ -729,8 +731,10 @@ int ua_monitor_start_absence_detection( if (monitor->service) if ((service && g_strcmp0(monitor->service, service)) || - (!service && g_strcmp0(monitor->service, UA_SERVICE_DEFAULT))) + (!service && g_strcmp0(monitor->service, UA_SERVICE_DEFAULT))) { + g_free(service); return UA_ERROR_NOT_PERMITTED; + } retv_if(UA_DETECT_MODE_INVALID <= mode, UA_ERROR_INVALID_PARAMETER); retv_if(0 == monitor->sensor_bitmask, UA_ERROR_NO_DATA); @@ -767,6 +771,8 @@ int ua_monitor_start_absence_detection( monitor->user_data = user_data; monitor->absence_detection_started = TRUE; + g_free(service); + FUNC_EXIT; return UA_ERROR_NONE; } diff --git a/test/uat-detections.c b/test/uat-detections.c index 7af64d1..6242e70 100644 --- a/test/uat-detections.c +++ b/test/uat-detections.c @@ -222,8 +222,8 @@ static int run_ua_monitor_set_user_presence_condition( if (strlen(g_presence_and_cond)) bitmask_and = (unsigned char)strtol(g_presence_and_cond, NULL, 10); - if (strlen(g_presence_and_cond)) - bitmask_or = (unsigned char)strtol(g_absence_and_cond, NULL, 10); + if (strlen(g_presence_or_cond)) + bitmask_or = (unsigned char)strtol(g_absence_or_cond, NULL, 10); msgb("AND [0x%u] OR [0x%u]", bitmask_and, bitmask_or); diff --git a/test/uat-init.c b/test/uat-init.c index 0005510..1859ec2 100644 --- a/test/uat-init.c +++ b/test/uat-init.c @@ -72,36 +72,50 @@ static const char * __convert_device_mac_type_to_txt(ua_mac_type_e mac_type) static void __user_presence_detected_foreach_devices(gpointer data, gpointer user_data) { + int ret; ua_device_h device_handle = (ua_device_h)data; char *account = (char *)user_data; ua_mac_type_e mac_type; char *mac = NULL; - ua_device_get_mac_address(device_handle, &mac); - ua_device_get_mac_type(device_handle, &mac_type); + ret = ua_device_get_mac_address(device_handle, &mac); + if (UA_ERROR_NONE != ret) { + msg(" - ua_device_get_mac_address() ret: [0x%X] [%s]", + ret, uat_get_error_str(ret)); + } + ret = ua_device_get_mac_type(device_handle, &mac_type); + if (UA_ERROR_NONE != ret) { + msg(" - ua_device_get_mac_type() ret: [0x%X] [%s]", + ret, uat_get_error_str(ret)); + } msgb("[%s] detected on [%s][%s]", account, __convert_device_mac_type_to_txt(mac_type), mac); + + g_free(mac); } static void __user_presence_detected_cb(int result, ua_monitor_h monitor, ua_user_h user_handle, GSList *device_handles, void *user_data) { + int ret; char *account = NULL; char *pbuf = uat_get_time(); msg("\n[%s]", pbuf); free(pbuf); - ua_user_get_account(user_handle, &account); + ret = ua_user_get_account(user_handle, &account); + if (UA_ERROR_NONE != ret) { + msg(" - ua_user_get_account() ret: [0x%X] [%s]", + ret, uat_get_error_str(ret)); + } msgb("[%s] PRESENCE detected [%s]", account, uat_get_error_str(result)); g_slist_foreach(device_handles, __user_presence_detected_foreach_devices, account); - if (account) { - free(account); - } + g_free(account); } static void __sensor_state_changed_cb(bool ready, |