sensor info memory issues
authorAbhay Agarwal <ay.agarwal@samsung.com>
Tue, 24 Sep 2019 03:53:06 +0000 (12:53 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 26 Sep 2019 06:44:56 +0000 (15:44 +0900)
Change-Id: I5a8cfee673741c30cb7c1cb24dbb562256669efe
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
include/ua-api.h
ua-api/src/ua-event-handler.c
ua-daemon/src/pm/ua-light-plugin-handler.c
ua-daemon/src/ua-manager-core.c

index ad15013..e3aa1e7 100644 (file)
@@ -485,7 +485,7 @@ typedef struct {
 } uam_device_info_s;
 
 /**
- * @brief Light info structure.
+ * @brief Sensor info structure.
  * @since_tizen 5.5
  */
 typedef struct {
index d0768cc..caecc48 100644 (file)
@@ -121,12 +121,11 @@ static void __uam_event_handler(GDBusConnection *connection,
                int accuracy, count;
                double values[UAM_SENSOR_MAX_VALUES];
 
-               UAM_DBG("Get sensor values");
-               memset(&sensor_info, 0, sizeof(uam_sensor_info_s));
-               memset(&sensor_info.values, 0, UAM_SENSOR_MAX_VALUES);
                g_variant_get(parameters, "(uxiidddd)", &sensor_bitmask, &timestamp,
                                                &accuracy, &count, &values[0], &values[1],
-                                               &values[2], &values[2]);
+                                               &values[2], &values[3]);
+               memset(&sensor_info, 0, sizeof(uam_sensor_info_s));
+               event = UAM_EVENT_PRESENCE_DETECTED;
                sensor_info.sensor_bitmask = sensor_bitmask;
                sensor_info.timestamp = timestamp;
                sensor_info.accuracy = accuracy;
@@ -140,9 +139,6 @@ static void __uam_event_handler(GDBusConnection *connection,
                                sensor_info.sensor_bitmask, sensor_info.timestamp,
                                sensor_info.accuracy, sensor_info.count, sensor_info.values[0],
                                sensor_info.values[1], sensor_info.values[2], sensor_info.values[3]);
-
-               event = UAM_EVENT_PRESENCE_DETECTED;
-
                __uam_send_event(event, result, &sensor_info,
                                event_info->cb, event_info->user_data);
        } else if (0 == strcasecmp(signal_name, UAM_SIGNAL_ABSENCE_DETECTED)) {
index 3effd70..e96e38b 100644 (file)
@@ -53,6 +53,7 @@ void light_detection_callback(uas_detection_type_e type, void *sensor_info)
 
        info = sensor_info;
        light_info = _pm_util_uas_sensor_info_to_uam_sensor_info(info);
+
        if (UAS_PRESENCE == type) {
                UAM_DBG("Presence detected by light sensor");
                _uam_core_handle_presence_detected(UAM_SENSOR_BITMASK_LIGHT, 0, light_info);
index 520a2a4..f003a64 100644 (file)
@@ -2383,7 +2383,6 @@ void _uam_core_handle_presence_detected(unsigned int sensor,
 
        UAM_INFO("sensor: 0x%8.8X, user_id: %d", sensor, user_id);
 
-       sensor_info = g_new0(uam_sensor_info_s, 1);
        if (info && (UAM_SENSOR_BITMASK_LIGHT == sensor || UAM_SENSOR_BITMASK_MOTION == sensor))
                sensor_info = info;
        if (info && (UAM_SENSOR_BITMASK_BLE == sensor || UAM_SENSOR_BITMASK_WIFI == sensor))