Fix coding guidelines issues
authorAbhay agarwal <ay.agarwal@samsung.com>
Fri, 27 Dec 2019 07:25:49 +0000 (12:55 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 30 Dec 2019 07:45:57 +0000 (16:45 +0900)
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
include/user-awareness.h
src/user-awareness-device.c
src/user-awareness-monitors.c
src/user-awareness-service.c
src/user-awareness-util.c
test/uat-common.c
test/uat-detections.c
test/uat-devices.c
test/uat-init.c
test/uat-payload.c
test/uat-service.c

index 22eaa9570adf064559f29de7028ed9bfd7fd0ebb..226862bb712f927cc4c54ad14c637d422bcfd915 100644 (file)
@@ -2679,7 +2679,7 @@ int ua_device_get_by_mac_address(
 int ua_device_get_by_device_id(
                const char *device_id,
                ua_mac_type_e mac_type,
-               ua_device_h * device_handle);
+               ua_device_h *device_handle);
 
 /**
  * @ingroup CAPI_NETWORK_UA_MODULE
@@ -2794,7 +2794,7 @@ int ua_device_foreach_added_by_user(
  * @see ua_payload_destroy()
  */
 int ua_payload_create(
-               ua_payload_h * payload_handle);
+               ua_payload_h *payload_handle);
 
 /**
  * @ingroup CAPI_NETWORK_UA_MODULE
index c1bf68082adbcffe5c2a12920986997bf6268529..a8fb7ff75e66b239f2576d4946323683a88d7790 100644 (file)
@@ -93,7 +93,7 @@ static ua_dev_info_s* __ua_add_device_info_to_list(uam_device_info_s *uam_info)
 
                dev->os = uam_info->operating_system;
                dev->pairing_required = FALSE;
-               dev->discriminant= true;
+               dev->discriminant = true;
                dev->isadded = true;
                return dev;
        }
@@ -171,7 +171,7 @@ ua_dev_info_s* _ua_get_device_info_from_uam(uam_device_info_s *uam_info)
        dev->type = _to_ua_mac_type(uam_info->type);
        dev->pairing_required = FALSE;
        dev->os = uam_info->operating_system;
-       dev->discriminant= uam_info->discriminant;
+       dev->discriminant = uam_info->discriminant;
        dev->isadded = true;
        dev->handle = (ua_device_h)dev;
 
@@ -787,7 +787,7 @@ int ua_device_get_by_mac_address(
 
        dev->type = _to_ua_mac_type(uam_dev.type);
        dev->pairing_required = FALSE;
-       dev->discriminant= uam_dev.discriminant;
+       dev->discriminant = uam_dev.discriminant;
        dev->os = uam_dev.operating_system;
        dev->isadded = true;
 
@@ -879,7 +879,7 @@ int ua_device_get_by_device_id(
        dev->type = _to_ua_mac_type(uam_dev.type);
        dev->pairing_required = FALSE;
        dev->os = uam_dev.operating_system;
-       dev->discriminant= uam_dev.discriminant;
+       dev->discriminant = uam_dev.discriminant;
        dev->isadded = true;
 
        /* Add device to list of devices */
@@ -1177,7 +1177,7 @@ int ua_device_foreach_added_by_user(
 
        if (ua_devices_user_list) {
                g_slist_free_full(ua_devices_user_list, _ua_free_ua_device_info_t);
-               ua_devices_user_list= NULL;
+               ua_devices_user_list = NULL;
        }
 
        for (i = 0; i < devices_list->len; i++) {
index 8b86e8de4baa34caa771ac21da95ce44a61438b7..c899641afcadd0fcd08a5ab793f2467e52b40e7b 100644 (file)
@@ -262,9 +262,8 @@ static gboolean __ua_monitor_check_presence_and_or_condition(ua_monitor_s *monit
        else
                condition_result = and_condition && or_condition;
 
-       if (!condition_result) {
+       if (!condition_result)
                UA_DBG("User presence AND/OR conditions failed");
-       }
 
        FUNC_EXIT;
        return condition_result;
@@ -327,7 +326,7 @@ static void __ua_monitor_send_user_presence_cb(ua_monitor_s *monitor,
 
        for (l = user_state->found_devices; l; l = g_slist_next(l)) {
                dev = (ua_dev_info_s *)l->data;
-               if(!dev)
+               if (!dev)
                        continue;
 
                UA_DBG("device id [%s], dev type [%u]", dev->device_id, dev->type);
@@ -558,9 +557,8 @@ static void __ua_sensor_presence_detected(ua_monitor_s *monitor,
 
        __ua_monitor_send_sensor_presence_cb(monitor, device_handle, sensor_info);
 
-       if (account && user_state) {
+       if (account && user_state)
                __ua_monitor_send_user_presence_cb(monitor, user_state);
-       }
 
        if (!account) {
                __ua_monitor_send_env_user_presence_cb(monitor);
index cc18dd5d515203ebbf343de53ec8491e57970762..eb0269910cd96fc56a770eec4243c7e30a1dd80c 100644 (file)
@@ -587,7 +587,7 @@ int ua_service_get_by_name(const char *name, ua_service_h *service_handle)
                }
        }
 
-       if(l == NULL) {
+       if (l == NULL) {
                        UA_ERR("Service [%s] is not found", name);
                        FUNC_EXIT;
                        return UA_ERROR_INVALID_PARAMETER;
index af99a2fd961aeebfbddea22c690fb29642bb1e13..11cc65683730baa88d16aa98011138542959cff1 100644 (file)
@@ -264,9 +264,8 @@ static int __ua_update_sensor_info(
        sensor->timestamp = info->timestamp;
        sensor->count = info->count;
        sensor->bitmask = info->bitmask;
-       for(i = 0; i < UA_SENSOR_MAX_VALUES; i++) {
+       for (i = 0; i < UA_SENSOR_MAX_VALUES; i++)
                sensor->values[i] = info->values[i];
-       }
 
        FUNC_EXIT;
        return UA_ERROR_NONE;
@@ -295,9 +294,8 @@ ua_sensor_info_s* _uam_to_ua_sensor_info(uam_sensor_info_s *info)
        sensor_info->timestamp = info->timestamp;
        sensor_info->count = info->count;
        sensor_info->bitmask = _uam_to_ua_sensor(info->sensor_bitmask);
-       for(i = 0; i < UA_SENSOR_MAX_VALUES; i++) {
+       for (i = 0; i < UA_SENSOR_MAX_VALUES; i++)
                sensor_info->values[i] = info->values[i];
-       }
 
        return sensor_info;
        FUNC_EXIT;
@@ -436,19 +434,17 @@ GSList *ua_sensor_get_info_values(
        GSList *values = NULL;
        ua_sensor_info_s *sensor;
 
-       if (!sensor_handle) {
+       if (!sensor_handle)
                goto done;
-       }
+
        UA_INFO("Sensor Handle [%p]", sensor_handle);
        sensor = (ua_sensor_info_s *)sensor_handle;
 
-       if (!sensor->values) {
+       if (!sensor->values)
                goto done;
-       }
 
-       for(i = 0; i < UA_SENSOR_MAX_VALUES; i++) {
+       for (i = 0; i < UA_SENSOR_MAX_VALUES; i++)
                values = g_slist_append(values, &sensor->values[i]);
-       }
 
 done:
        FUNC_EXIT;
index 97b0c3da934796e8460a045105e630f9258663ed..402ca9b4978d9e02bbfa44b917bde4c359e99b03 100644 (file)
@@ -158,7 +158,7 @@ char* uat_get_time()
 void uat_print_device_uid(const char *device_uid)
 {
        fprintf(stdout, ANSI_COLOR_WHITE "payload device_uid :" ANSI_COLOR_NORMAL);
-       if(!device_uid)
+       if (!device_uid)
                goto done;
 
        for (int i = 0; i < UA_BLE_PAYLOAD_DEVICE_UID_MAX_LEN; i++)
index 43f6d027239fe867ddc47f40785d38f87f0d0be7..394076a981bed65762b6c2356b8d3d99a16ce57f 100644 (file)
@@ -98,9 +98,8 @@ static void __sensor_detected_sensor_info(int type,
        }
 
        values = ua_sensor_get_info_values(sensor_handle);
-       if (NULL == values) {
+       if (NULL == values)
                msg(" - ua_sensor_get_info_values() failed");
-       }
 
        for (l = values; l; l = g_slist_next(l)) {
                value = (double *)l->data;
@@ -239,9 +238,8 @@ static int run_ua_get_detection_cycle(
        }
 
        ret = ua_get_detection_cycle(g_service_h, &cycle_value);
-       if (UA_ERROR_NONE == ret) {
+       if (UA_ERROR_NONE == ret)
                snprintf(cycle_time, sizeof(cycle_time), "%u", cycle_value);
-       }
 
        msg(" - ua_get_detection_cycle() ret: [0x%X] [%s]",
                        ret, uat_get_error_str(ret));
@@ -623,7 +621,7 @@ static int run_ua_set_low_power_mode(
 
        msg("ua_set_low_power_mode bitmask [%x]", sensor);
 
-       ret =ua_set_low_power_mode(sensor, onoff == 1 ? true : false);
+       ret = ua_set_low_power_mode(sensor, onoff == 1 ? true : false);
 
        msg(" - ua_set_low_power_mode() ret: [0x%X] [%s]",
                        ret, uat_get_error_str(ret));
@@ -640,20 +638,19 @@ static int run_device_power_request_poweroff(
 
        msg("device_power_request_poweroff");
 
-    if (0 != device_power_request_poweroff(off_reason))  {
-        msgr("Fail to request power off");
-        return false;
-    }
+       if (0 != device_power_request_poweroff(off_reason))  {
+               msgr("Fail to request power off");
+               return false;
+       }
 
        ret = device_power_set_wakeup_reason(POWER_WAKEUP_REASON_AMBIENT_READY);
-       if(POWER_ERROR_NONE != ret)
-       {
+       if (POWER_ERROR_NONE != ret) {
                msgr("Fail to set wakeup reason");
                return RET_SUCCESS;
        }
 
        ret = device_power_set_state(POWER_STATE_STANDBY, 1);
-       if(POWER_ERROR_NONE != ret) {
+       if (POWER_ERROR_NONE != ret) {
                msgr("Failed to request TV to STANDBY!");
                return RET_SUCCESS;
        }
index d3db478ed77c72dcd759bd336875688610abab89..74bffdbafe857a8ca7e1791a6390bd412838b194 100644 (file)
@@ -184,9 +184,8 @@ void uat_update_device_info(void)
        }
 
        ret = ua_device_get_discriminant(g_device_h, &discriminant);
-       if (UA_ERROR_NONE == ret) {
+       if (UA_ERROR_NONE == ret)
                snprintf(g_discriminant, MENU_DATA_SIZE + 1, "%d", discriminant ? 1 : 0);
-       }
 
        ret = ua_device_get_wifi_ipv4_address(g_device_h, &ipv4);
        if (UA_ERROR_NONE == ret && ipv4) {
index 2a690563c904e88b6b4ce5ddf414c560ef2f5a75..5e462141da4d29e3651f5264b58237ef871da189 100644 (file)
@@ -73,9 +73,8 @@ static void __user_detected_foreach_sensors(gpointer data,
        }
 
        values = ua_sensor_get_info_values(sensor_handle);
-       if (NULL == values) {
+       if (NULL == values)
                msg(" - ua_sensor_get_info_values() failed");
-       }
 
        for (l = values; l; l = g_slist_next(l)) {
                value = (double *)l->data;
@@ -112,11 +111,10 @@ static void __user_absence_detected_cb(int result, ua_monitor_h monitor,
        msgr("[%s] ABSENCE detected [%s]", account, uat_get_error_str(result));
 
        g_slist_foreach(sensor_handles,
-               __user_detected_foreach_sensors, (void* )UAT_ABSENCE);
+               __user_detected_foreach_sensors, (void*)UAT_ABSENCE);
 
-       if (account) {
+       if (account)
                free(account);
-       }
 }
 
 const char * uat_convert_device_mac_type_to_txt(ua_mac_type_e mac_type)
@@ -181,9 +179,8 @@ static void __user_presence_detected_cb(int result, ua_monitor_h monitor,
                g_slist_foreach(device_handles, __user_presence_detected_foreach_devices, account);
        }
 
-       if (!account) {
+       if (!account)
                msgbr("[No user information] PRESENCE detected [%s]", uat_get_error_str(result));
-       }
 
        g_slist_foreach(sensor_handles,
                        __user_detected_foreach_sensors, (void *)UAT_PRESENCE);
@@ -243,9 +240,8 @@ static void __sensor_status_changed_cb(ua_monitor_h handle,
        }
 
        values = ua_sensor_get_info_values(sensor_handle);
-       if (NULL == values) {
+       if (NULL == values)
                msg(" - ua_sensor_get_info_values() failed");
-       }
 
        for (l = values; l; l = g_slist_next(l)) {
                value = (double *)l->data;
@@ -505,7 +501,7 @@ static int _scan_ibeacon_adv_str(
 
        for (int i = 0; i < length; i++) {
                ret = fscanf(stdin, "%d", &temp);
-               if(!ret)
+               if (!ret)
                        msg(" - fscanf ret: %d", ret);
 
                g_ibeacon_adv_str[i] = (unsigned char)temp;
index eac06eafdfee952d656ec8b57c44bbd7a862ed15..acfb56abeb8faf58812c277b39c018cafbfcdd01 100644 (file)
@@ -148,7 +148,7 @@ static int _scan_payload_device_uid_str(
 
        for (int i = 0; i < device_uid_len; i++) {
                ret = fscanf(stdin, "%d", &temp);
-               if(!ret)
+               if (!ret)
                        msg(" - fscanf ret: %d", ret);
 
                g_payload_device_uid_str[i] = (unsigned char)temp;
@@ -306,13 +306,12 @@ static bool __foreach_added_payload_cb(
                msglr("Payload secondary key : %d", secondary_key);
 
        ret = ua_payload_get_device_uid_len(handle, &device_uid_len);
-       if (UA_ERROR_NONE == ret) {
+       if (UA_ERROR_NONE == ret)
                msglr("Payload device uid len  %d", device_uid_len);
-       }
 
        ret = ua_payload_get_device_uid(handle, &device_uid);
        if (UA_ERROR_NONE == ret) {
-               for (int i = 0; i < device_uid_len; i++ )
+               for (int i = 0; i < device_uid_len; i++)
                        msglr("Payload device uid 0x%2.2X", device_uid[i]);
        }
 
@@ -322,7 +321,7 @@ static bool __foreach_added_payload_cb(
 
        ret = ua_payload_get_user_data(handle, &payload_user_data);
        if (UA_ERROR_NONE == ret) {
-               for (int i = 0; i < 17 - 1 - device_uid_len; i++ )
+               for (int i = 0; i < 17 - 1 - device_uid_len; i++)
                        msglr("Payload user data : 0x%2.2X", payload_user_data[i]);
        }
 
index fdb10b0fe94293c69b4513f35c830655f32bc3a7..1125fc3ae39211539a7726f2760c38b6f6357342 100644 (file)
@@ -271,33 +271,33 @@ static bool _service_foreach_added_device_cb(
 
 static int uat_select_service(MManager *mm, struct menu_data *menu)
 {
-    GSList *iter = g_service_list;
-
-    int id = 0;
-    int selected_id = 0;
-
-    if (strlen(g_selected_service_id))
-        selected_id = (unsigned char)strtol(g_selected_service_id, NULL, 10);
-
-    if (selected_id <= 0) {
-        msg("Please select service first");
-        return RET_SUCCESS;
-    }
-
-    while (NULL != iter) {
-        GSList *next = iter->next;
-        ua_service_h *handle = iter->data;
-        if (handle && ++id == selected_id) {
-            /* Make selected service as a current one */
-            g_service_h = handle;
-            __update_service_info();
-            msg("Select service done");
-            return RET_SUCCESS;
-        }
-        iter = next;
-    }
-
-    return RET_SUCCESS;
+       GSList *iter = g_service_list;
+
+       int id = 0;
+       int selected_id = 0;
+
+       if (strlen(g_selected_service_id))
+               selected_id = (unsigned char)strtol(g_selected_service_id, NULL, 10);
+
+       if (selected_id <= 0) {
+               msg("Please select service first");
+               return RET_SUCCESS;
+       }
+
+       while (NULL != iter) {
+               GSList *next = iter->next;
+               ua_service_h *handle = iter->data;
+               if (handle && ++id == selected_id) {
+                   /* Make selected service as a current one */
+                   g_service_h = handle;
+                   __update_service_info();
+                   msg("Select service done");
+                   return RET_SUCCESS;
+               }
+               iter = next;
+       }
+
+       return RET_SUCCESS;
 }
 
 static int run_ua_service_create(