Add comments for line coverage 83/241883/2 accepted/tizen/5.5/unified/20200827.041651 submit/tizen_5.5/20200825.012738
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 20 Aug 2020 12:14:46 +0000 (21:14 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Fri, 21 Aug 2020 02:14:15 +0000 (11:14 +0900)
Change-Id: I76cef1f7df29a0052e05f9022adc3e20a2ed1c97
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/battery.c
src/callback.c
src/common.c
src/dbus.c
src/display.c
src/haptic.c
src/ir.c
src/led.c
src/power.c
src/temperature.c
src/touchscreen-internal.c

index d4404b1..c5ed16e 100644 (file)
@@ -51,11 +51,15 @@ static int is_battery_supported(void)
 
        ret = system_info_get_platform_bool(BATTERY_FEATURE, &battery_avail);
        if (ret < 0) {
+//LCOV_EXCL_START System Error
                _E("Failed to get value of battery feature");
                return false;
+//LCOV_EXCL_STOP
        } else if (ret == 0 && !battery_avail) {
+//LCOV_EXCL_START System Error
                _D("Battery is not supported");
                return false;
+//LCOV_EXCL_STOP
        } else
                return true;
 }
@@ -211,8 +215,6 @@ out:
        return ret;
 }
 
-//LCOV_EXCL_START unused function
-
 static int load_battery_plugin()
 {
        if (plugin_battery_get_info)
@@ -221,15 +223,19 @@ static int load_battery_plugin()
        if (!handle) {
                handle = dlopen(BATTERY_PLUGIN, RTLD_NOW);
                if (!handle) {
+//LCOV_EXCL_START System Error
                        _E("Failed to open '%s' : %s", BATTERY_PLUGIN, dlerror());
                        return -1;
+//LCOV_EXCL_STOP
                }
        }
 
        plugin_battery_get_info = (int (*)(void *))dlsym(handle, GET_INFO_FUNC);
        if (!plugin_battery_get_info) {
+//LCOV_EXCL_START System Error
                _E("Failed to get symbol '%s' : %s", GET_INFO_FUNC, dlerror());
                return -1;
+//LCOV_EXCL_STOP
        }
 
        return 0;
@@ -251,13 +257,14 @@ int device_battery_get_info_direct(struct device_battery_info *info)
 
        ret = plugin_battery_get_info(info);
        if (ret < 0) {
+//LCOV_EXCL_START System Error
                _E("Failed to get battery info: %d", ret);
                return DEVICE_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_STOP
        }
 
        return DEVICE_ERROR_NONE;
 }
-//LCOV_EXCL_STOP
 
 int device_battery_get_health(device_battery_health_e *health)
 {
index f4d7d45..ff96a74 100644 (file)
@@ -175,9 +175,11 @@ static int register_signal(const char *bus_name,
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
        if (!conn) {
-               _E("fail to get dbus connection : %s", err->message); //LCOV_EXCL_LINE
-               g_clear_error(&err); //LCOV_EXCL_LINE System Error
+//LCOV_EXCL_START System Error
+               _E("fail to get dbus connection : %s", err->message);
+               g_clear_error(&err);
                return -EPERM;
+//LCOV_EXCL_STOP
        }
 
        /* subscribe signal */
@@ -192,8 +194,10 @@ static int register_signal(const char *bus_name,
                        NULL,
                        NULL);
        if (id == 0) {
-               _E("fail to connect %s signal", signal); //LCOV_EXCL_LINE
+//LCOV_EXCL_START System Error
+               _E("fail to connect %s signal", signal);
                return -EPERM;
+//LCOV_EXCL_STOP
        }
 
        if (sig_id)
@@ -212,9 +216,11 @@ static int unregister_signal(int *sig_id)
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
        if (!conn) {
-               _E("fail to get dbus connection : %s", err->message); //LCOV_EXCL_LINE
-               g_clear_error(&err); //LCOV_EXCL_LINE System Error
+//LCOV_EXCL_START System Error
+               _E("fail to get dbus connection : %s", err->message);
+               g_clear_error(&err);
                return -EPERM;
+//LCOV_EXCL_STOP
        }
 
        /* unsubscribe signal */
@@ -355,7 +361,7 @@ int device_remove_callback(device_callback_e type, device_changed_cb cb)
        if (n == 0) {
                ret = release_request(type);
                if (ret < 0)
-                       return DEVICE_ERROR_OPERATION_FAILED;
+                       return DEVICE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE System Error
        }
 
        return DEVICE_ERROR_NONE;
index b455fef..399becb 100644 (file)
@@ -59,8 +59,10 @@ int config_parse(const char *file_name, int cb(struct parse_result *result,
        int lineno = 0, ret = 0;
 
        if (!file_name || !cb) {
+//LCOV_EXCL_START System Error
                ret = -EINVAL;
                goto error;
+//LCOV_EXCL_STOP
        }
 
        /* open conf file */
@@ -94,8 +96,10 @@ int config_parse(const char *file_name, int cb(struct parse_result *result,
                        /* parse section */
                        end = strchr(start, ']');
                        if (!end || *end != ']') {
+//LCOV_EXCL_START System Error
                                ret = -EBADMSG;
                                goto error;
+//LCOV_EXCL_STOP
                        }
 
                        *end = '\0';
@@ -105,8 +109,10 @@ int config_parse(const char *file_name, int cb(struct parse_result *result,
                        /* parse name & value */
                        end = strchr(start, '=');
                        if (!end || *end != '=') {
+//LCOV_EXCL_START System Error
                                ret = -EBADMSG;
                                goto error;
+//LCOV_EXCL_STOP
                        }
                        *end = '\0';
                        name = trim_str(start);
@@ -123,8 +129,10 @@ int config_parse(const char *file_name, int cb(struct parse_result *result,
                        /* callback with parse result */
                        ret = cb(&result, user_data);
                        if (ret < 0) {
+//LCOV_EXCL_START System Error
                                ret = -EBADMSG;
                                goto error;
+//LCOV_EXCL_STOP
                        }
                }
        }
@@ -132,8 +140,8 @@ int config_parse(const char *file_name, int cb(struct parse_result *result,
        fclose(f);
        return 0;
 
-error:
 //LCOV_EXCL_START System Error
+error:
        if (f)
                fclose(f);
        _E("Failed to read %s:%d!", file_name, lineno);
@@ -217,6 +225,7 @@ int check_async_call_rate(void)
        return 0;
 }
 
+//LCOV_EXCL_START Not used function
 bool is_emulator(void)
 {
        int ret;
@@ -241,6 +250,7 @@ bool is_emulator(void)
 
        return emul;
 }
+//EXCL_LCOV_STOP
 
 int is_display_supported(void)
 {
@@ -249,11 +259,15 @@ int is_display_supported(void)
 
        ret = system_info_get_platform_bool(DISPLAY_FEATURE, &display_avail);
        if (ret < 0) {
+//LCOV_EXCL_START System Error
                _E("Failed to get value of display feature");
                return false;
+//LCOV_EXCL_STOP
        } else if (ret == 0 && !display_avail) {
+//LCOV_EXCL_START System Error
                _D("Display feature is not supported");
                return false;
+//LCOV_EXCL_STOP
        } else
                return true;
 }
@@ -265,11 +279,15 @@ int is_display_state_supported(void)
 
        ret = system_info_get_platform_bool(DISPLAY_STATE_FEATURE, &display_state_avail);
        if (ret < 0) {
+//LCOV_EXCL_START System Error
                _E("Failed to get value of display state feature");
                return false;
+//LCOV_EXCL_STOP
        } else if (ret == 0 && !display_state_avail) {
+//LCOV_EXCL_START System Error
                _D("Display state feature is not supported");
                return false;
+//LCOV_EXCL_STOP
        } else
                return true;
 }
index 6290e79..e07d720 100644 (file)
@@ -185,8 +185,8 @@ static GDBusProxy *get_proxy_from_proxy_pool(const char *dest,
                        g_set_error(err, G_IO_ERROR,
                                        G_IO_ERROR_INVALID_ARGUMENT,
                                        "Cannot determine destination address");
-//LCOV_EXCL_STOP
                return NULL;
+//LCOV_EXCL_STOP
        }
 
        /* find matched proxy node in proxy pool */
@@ -298,6 +298,7 @@ int dbus_method_sync_var(const char *dest, const char *path,
        return result;
 }
 
+//LCOV_EXCL_START Not used function
 int dbus_method_sync(const char *dest, const char *path,
                const char *interface, const char *method,
                const char *sig, const char *param[])
@@ -308,6 +309,7 @@ int dbus_method_sync(const char *dest, const char *path,
                                method,
                                append_g_variant(sig, param));
 }
+//EXCL_LCOV_STOP
 
 int dbus_method_sync_with_reply_var(const char *dest,
                const char *path, const char *interface,
@@ -362,6 +364,7 @@ int dbus_method_sync_with_reply_var(const char *dest,
        return DEVICE_ERROR_NONE;
 }
 
+//LCOV_EXCL_START Not used function
 int dbus_method_sync_with_reply(const char *dest,
                const char *path, const char *interface,
                const char *method, const char *sig,
@@ -374,6 +377,7 @@ int dbus_method_sync_with_reply(const char *dest,
                                append_g_variant(sig, param),
                                info);
 }
+//EXCL_LCOV_STOP
 
 static void cb_pending(GDBusProxy *proxy,
                GAsyncResult *res,
@@ -387,7 +391,7 @@ static void cb_pending(GDBusProxy *proxy,
                        res, /* GAsyncResult */
                        &err);
        if (!output)
-               _E("g_dbus_proxy_call_finish error : %d-%s", //LCOV_EXCL_LINE
+               _E("g_dbus_proxy_call_finish error : %d-%s", //LCOV_EXCL_LINE Logs
                                err?err->code:0, err?err->message:"NULL");
 
        if (data && data->func)
@@ -432,9 +436,10 @@ int dbus_method_async_with_reply_var(const char *dest, const char *path,
        pdata = malloc(sizeof(struct pending_call_data));
        if (!pdata) {
                pthread_mutex_unlock(&dmutex);
-               _E("malloc error : %s-%s", //LCOV_EXCL_LINE
-                               interface, method);
+//LCOV_EXCL_START System Error
+               _E("malloc error : %s-%s", interface, method);
                return -ENOMEM;
+//LCOV_EXCL_STOP
        }
 
        pdata->func = cb;
@@ -526,8 +531,10 @@ int register_signal_handler(void)
 
        g_object_unref(conn);
        if (haptic_id == 0) {
-               _E("Failed to subscrive bus signal"); //LCOV_EXCL_LINE System Error
+//LCOV_EXCL_START System Error
+               _E("Failed to subscrive bus signal");
                return -EPERM;
+//LCOV_EXCL_STOP
        }
 
        return 0;
index 850e159..02f5c19 100644 (file)
@@ -77,7 +77,7 @@ int device_display_get_numbers(int *device_number)
                                DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
                                METHOD_GET_DISPLAY_COUNT, NULL);
                if (ret < 0)
-                       return errno_to_device_error(ret);
+                       return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
                display_cnt = ret;
                alloc_display();
        }
@@ -115,7 +115,7 @@ int device_display_get_max_brightness(int display_index, int *max_brightness)
                                DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
                                METHOD_GET_MAX_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL));
                if (ret < 0)
-                       return errno_to_device_error(ret);
+                       return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
                display_arr[display_index].normal_max = ret;
        }
 
@@ -147,7 +147,7 @@ int device_display_get_brightness(int display_index, int *brightness)
                        DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
                        METHOD_GET_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL));
        if (ret < 0)
-               return errno_to_device_error(ret);
+               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
 
        *brightness = ret;
        return DEVICE_ERROR_NONE;
@@ -180,7 +180,7 @@ int device_display_set_brightness(int display_index, int brightness)
                        DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
                        METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", (int)DISPLAY_STATE_NORMAL, brightness));
        if (ret < 0)
-               return errno_to_device_error(ret);
+               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
 
        return DEVICE_ERROR_NONE;
 }
@@ -253,9 +253,11 @@ int device_display_change_state(display_state_e state)
                return DEVICE_ERROR_NOT_SUPPORTED;
 
        if (check_async_call_rate() < 0) {
+//LCOV_EXCL_START System Error
                _E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
                                , CHECK_RATE_THRESHOLD);
                return DEVICE_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_STOP
        }
 
        if (state < DISPLAY_STATE_NORMAL || state > DISPLAY_STATE_SCREEN_OFF)
@@ -282,7 +284,6 @@ int device_display_change_state(display_state_e state)
                        METHOD_CHANGE_STATE, g_variant_new("(s)", str), change_cb, -1, NULL);
 }
 
-//LCOV_EXCL_START Not used function
 int device_display_get_max_brightness_state(int display_index, display_state_e state, int *brightness)
 {
        int ret;
@@ -325,9 +326,7 @@ int device_display_get_max_brightness_state(int display_index, display_state_e s
 
        return DEVICE_ERROR_NONE;
 }
-//LCOV_EXCL_STOP
 
-//LCOV_EXCL_START Not used function
 int device_display_get_brightness_state(int display_index, display_state_e state, int *brightness)
 {
        int ret;
@@ -361,9 +360,7 @@ int device_display_get_brightness_state(int display_index, display_state_e state
 
        return DEVICE_ERROR_NONE;
 }
-//LCOV_EXCL_STOP
 
-//LCOV_EXCL_START Not used function
 int device_display_set_brightness_state(int display_index, display_state_e state, int brightness)
 {
        int ret, max;
@@ -420,5 +417,3 @@ int device_display_change_state_by_reason(display_state_e type, const char *reas
 
        return errno_to_device_error(ret);
 }
-
-//LCOV_EXCL_STOP
index 62d7a45..e9fe126 100644 (file)
@@ -60,11 +60,15 @@ static int is_haptic_supported(void)
 
        ret = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
        if (ret < 0) {
+//LCOV_EXCL_START System Error
                _E("Failed to get value of haptic feature");
                return false;
+//LCOV_EXCL_STOP
        } else if (ret == 0 && !haptic_avail) {
+//LCOV_EXCL_START System Error
                _D("Haptic is not supported");
                return false;
+//LCOV_EXCL_STOP
        } else
                return true;
 }
@@ -170,7 +174,7 @@ int device_haptic_open(int device_index, haptic_device_h *device_handle)
        if (DD_LIST_LENGTH(handle_list) == 1) {
                ret = register_signal_handler();
                if (ret < 0)
-                       _E("Faild to register signal handler"); //LCOV_EXCL_LINE
+                       _E("Faild to register signal handler"); //LCOV_EXCL_LINE Logs
        }
 
        return DEVICE_ERROR_NONE;
@@ -215,7 +219,7 @@ int device_haptic_close(haptic_device_h device_handle)
        if (DD_LIST_LENGTH(handle_list) == 0) {
                ret = unregister_signal_handler();
                if (ret < 0)
-                       _E("Failed to unregister signal handler"); //LCOV_EXCL_LINE
+                       _E("Failed to unregister signal handler"); //LCOV_EXCL_LINE Logs
        }
 
        return DEVICE_ERROR_NONE;
index 71b9db7..eb90724 100644 (file)
--- a/src/ir.c
+++ b/src/ir.c
@@ -76,8 +76,10 @@ int device_ir_transmit(int carrier_frequency, int *pattern, int size)
                        _E("IR is not supported or IR operation failed");
                        return ret;
                }
-               _E("IR is not supported"); //LCOV_EXCL_LINE
+//LCOV_EXCL_START System Error
+               _E("IR is not supported");
                return DEVICE_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_STOP
        }
 //LCOV_EXCL_START System Error
        if (!pattern)
index 3f65144..8ab2226 100644 (file)
--- a/src/led.c
+++ b/src/led.c
@@ -131,10 +131,9 @@ int device_led_play_custom(int on, int off, unsigned int color, unsigned int fla
        ret = dbus_method_sync_var(DEVICED_BUS_NAME,
                        DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
                        METHOD_PLAY_CUSTOM, g_variant_new("(iiuu)", on, off, (unsigned int)color, (unsigned int)flags));
-//LCOV_EXCL_START System Error
        if (ret < 0)
-               return errno_to_device_error(ret);
-//LCOV_EXCL_STOP
+               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+
        return DEVICE_ERROR_NONE;
 }
 
@@ -148,15 +147,12 @@ int device_led_stop_custom(void)
        ret = dbus_method_sync_var(DEVICED_BUS_NAME,
                        DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
                        METHOD_STOP_CUSTOM, NULL);
-//LCOV_EXCL_START System Error
        if (ret < 0)
-               return errno_to_device_error(ret);
-//LCOV_EXCL_STOP
+               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
 
        return DEVICE_ERROR_NONE;
 }
 
-//LCOV_EXCL_START Not used function
 int device_multi_led_get_number(int *num_of_leds)
 {
        int ret;
@@ -209,4 +205,3 @@ int device_multi_led_control(unsigned int color[])
        return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED,
                                DEVICED_INTERFACE_LED, METHOD_MULTI_LED_CONTROL, var);
 }
-//LCOV_EXCL_STOP
index f4c6fe7..feb9431 100644 (file)
@@ -440,9 +440,11 @@ int device_power_request_lock(power_lock_e type, int timeout_ms)
        _I("power_lock_e = %d", type);
 
        if (check_async_call_rate() < 0) {
+//LCOV_EXCL_START System Error
                _E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
                                , CHECK_RATE_THRESHOLD);
                return DEVICE_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_STOP
        }
 
        if (timeout_ms < 0)
@@ -470,9 +472,11 @@ int device_power_release_lock(power_lock_e type)
        _I("power_lock_e = %d", type);
 
        if (check_async_call_rate() < 0) {
+//LCOV_EXCL_START System Error
                _E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
                                , CHECK_RATE_THRESHOLD);
                return DEVICE_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_STOP
        }
 
        if (type == POWER_LOCK_CPU) {
@@ -559,5 +563,5 @@ static void __CONSTRUCTOR__ power_init(void)
 
        ret = config_parse(POWER_CONF, power_load_config, NULL);
        if (ret < 0)
-               _E("Failed to load config file (%d)", ret); //LCOV_EXCL_LINE
+               _E("Failed to load config file (%d)", ret); //LCOV_EXCL_LINE Logs
 }
index 9064517..36e3cb9 100644 (file)
@@ -43,11 +43,15 @@ static int is_temperature_supported(device_thermal_e type)
        else
                ret = system_info_get_platform_bool(THERMAL_BATTERY_FEATURE, &thermal_avail);
        if (ret < 0) {
+//LCOV_EXCL_START System Error
                _E("Failed to get value of temp feature : %d", ret);
                return false;
+//LCOV_EXCL_STOP
        } else if (ret == 0 && !thermal_avail) {
+//LCOV_EXCL_START System Error
                _D("Temperature is not supported");
                return false;
+//LCOV_EXCL_STOP
        } else
                return true;
 }
@@ -68,7 +72,7 @@ int device_thermal_get_temperature(device_thermal_e type, int *temp)
                        DEVICED_INTERFACE_TEMPERATURE,
                        METHOD_GET_TEMPERATURE, g_variant_new("(i)", type));
        if (ret < 0)
-               return errno_to_device_error(ret);
+               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
 
        *temp = ret;
        return DEVICE_ERROR_NONE;
index 6220273..c0939f3 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #include "common.h"
 #include "dbus.h"
 #include "touchscreen-internal.h"
@@ -8,6 +24,7 @@
 int device_touchscreen_enable(device_dbus_pending_cb cb)
 {
        int ret;
+
        ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
                        DEVICED_PATH_TOUCH, DEVICED_INTERFACE_TOUCH,
                        METHOD_TOUCHSCREEN_ENABLE, NULL, NULL, cb, -1, NULL);
@@ -18,6 +35,7 @@ int device_touchscreen_enable(device_dbus_pending_cb cb)
 int device_touchscreen_disable(device_dbus_pending_cb cb)
 {
        int ret;
+
        ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
                        DEVICED_PATH_TOUCH, DEVICED_INTERFACE_TOUCH,
                        METHOD_TOUCHSCREEN_DISABLE, NULL, NULL, cb, -1, NULL);