Add comments for line/function coverage analysis 88/71088/3
authorpr.jung <pr.jung@samsung.com>
Tue, 24 May 2016 05:07:54 +0000 (14:07 +0900)
committerpr.jung <pr.jung@samsung.com>
Tue, 24 May 2016 06:43:58 +0000 (15:43 +0900)
- Remove system error, not used function, not supported feature and logs.
- Drops the exclusion reason for Logs

Change-Id: I185107755c5717ee5a3dde91e1943a0b8517c3a4
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/dbus.c
src/feedback.c
src/parser.c
src/sound.c
src/vibrator.c

index 952932d..1c66641 100644 (file)
@@ -92,13 +92,13 @@ int dbus_method_sync(const char *dest, const char *path,
 
        conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
        if (!conn) {
-               _E("dbus_bus_get error");
+               _E("dbus_bus_get error"); //LCOV_EXCL_LINE
                return -EPERM;
        }
 
        msg = dbus_message_new_method_call(dest, path, interface, method);
        if (!msg) {
-               _E("dbus_message_new_method_call(%s:%s-%s)",
+               _E("dbus_message_new_method_call(%s:%s-%s)", //LCOV_EXCL_LINE
                        path, interface, method);
                return -EBADMSG;
        }
@@ -106,7 +106,7 @@ int dbus_method_sync(const char *dest, const char *path,
        dbus_message_iter_init_append(msg, &iter);
        ret = append_variant(&iter, sig, param);
        if (ret < 0) {
-               _E("append_variant error(%d) %s %s:%s-%s",
+               _E("append_variant error(%d) %s %s:%s-%s", //LCOV_EXCL_LINE
                        ret, dest, path, interface, method);
                dbus_message_unref(msg);
                return ret;
@@ -117,18 +117,18 @@ int dbus_method_sync(const char *dest, const char *path,
        reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
        dbus_message_unref(msg);
        if (!reply) {
-               _E("dbus_connection_send error(%s:%s) %s %s:%s-%s",
+               _E("dbus_connection_send error(%s:%s) %s %s:%s-%s", //LCOV_EXCL_LINE
                        err.name, err.message, dest, path, interface, method);
-               dbus_error_free(&err);
+               dbus_error_free(&err); //LCOV_EXCL_LINE System Error
                return -ECOMM;
        }
 
        ret = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
        dbus_message_unref(reply);
        if (!ret) {
-               _E("no message : [%s:%s] %s %s:%s-%s",
+               _E("no message : [%s:%s] %s %s:%s-%s", //LCOV_EXCL_LINE
                        err.name, err.message, dest, path, interface, method);
-               dbus_error_free(&err);
+               dbus_error_free(&err); //LCOV_EXCL_LINE System Error
                return -ENOMSG;
        }
 
index c651c5c..d807162 100644 (file)
@@ -37,7 +37,7 @@ API int feedback_initialize(void)
 {
        pthread_mutex_lock(&fmutex);
        if (!profile) {
-               _E("there is no valid profile module.");
+               _E("there is no valid profile module."); //LCOV_EXCL_LINE
                pthread_mutex_unlock(&fmutex);
                return FEEDBACK_ERROR_NOT_SUPPORTED;
        }
@@ -91,7 +91,7 @@ API int feedback_play(feedback_pattern_e pattern)
        /* check initialize */
        pthread_mutex_lock(&fmutex);
        if (!init_cnt) {
-               _E("Not initialized");
+               _E("Not initialized"); //LCOV_EXCL_LINE
                pthread_mutex_unlock(&fmutex);
                return FEEDBACK_ERROR_NOT_INITIALIZED;
        }
@@ -107,7 +107,7 @@ API int feedback_play(feedback_pattern_e pattern)
        if (profile->get_switched_pattern) {
                result = profile->get_switched_pattern(pattern, &switched);
                if (result) {
-                       _W("pattern is changed : (%s) -> (%s)",
+                       _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
                                        profile->str_pattern[pattern], profile->str_pattern[switched]);
                        pattern = switched;
                }
@@ -138,7 +138,7 @@ API int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern)
        /* check initialize */
        pthread_mutex_lock(&fmutex);
        if (!init_cnt) {
-               _E("Not initialized");
+               _E("Not initialized"); //LCOV_EXCL_LINE
                pthread_mutex_unlock(&fmutex);
                return FEEDBACK_ERROR_NOT_INITIALIZED;
        }
@@ -160,7 +160,7 @@ API int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern)
        if (profile->get_switched_pattern) {
                result = profile->get_switched_pattern(pattern, &switched);
                if (result) {
-                       _W("pattern is changed : (%s) -> (%s)",
+                       _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
                                        profile->str_pattern[pattern], profile->str_pattern[switched]);
                        pattern = switched;
                }
@@ -169,7 +169,7 @@ API int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern)
        /* play proper device */
        dev = find_device(type);
        if (!dev) {
-               _E("Not supported device : type(%s)", profile->str_type[type]);
+               _E("Not supported device : type(%s)", profile->str_type[type]); //LCOV_EXCL_LINE
                return FEEDBACK_ERROR_NOT_SUPPORTED;
        }
 
@@ -191,7 +191,7 @@ API int feedback_stop(void)
        /* check initialize */
        pthread_mutex_lock(&fmutex);
        if (!init_cnt) {
-               _E("Not initialized");
+               _E("Not initialized"); //LCOV_EXCL_LINE
                pthread_mutex_unlock(&fmutex);
                return FEEDBACK_ERROR_NOT_INITIALIZED;
        }
@@ -220,7 +220,7 @@ API int feedback_is_supported_pattern(feedback_type_e type, feedback_pattern_e p
        /* check initialize */
        pthread_mutex_lock(&fmutex);
        if (!init_cnt) {
-               _E("Not initialized");
+               _E("Not initialized"); //LCOV_EXCL_LINE
                pthread_mutex_unlock(&fmutex);
                return FEEDBACK_ERROR_NOT_INITIALIZED;
        }
@@ -247,7 +247,7 @@ API int feedback_is_supported_pattern(feedback_type_e type, feedback_pattern_e p
        if (profile->get_switched_pattern) {
                result = profile->get_switched_pattern(pattern, &switched);
                if (result) {
-                       _W("pattern is changed : (%s) -> (%s)",
+                       _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
                                        profile->str_pattern[pattern], profile->str_pattern[switched]);
                        pattern = switched;
                }
@@ -256,17 +256,17 @@ API int feedback_is_supported_pattern(feedback_type_e type, feedback_pattern_e p
        /* play proper device */
        dev = find_device(type);
        if (!dev) {
-               _E("Not supported device : type(%s)", profile->str_type[type]);
+               _E("Not supported device : type(%s)", profile->str_type[type]); //LCOV_EXCL_LINE
                return FEEDBACK_ERROR_NOT_SUPPORTED;
        }
 
        err = dev->is_supported(pattern, &supported);
        if (err == -ENOTSUP)
-               return FEEDBACK_ERROR_NOT_SUPPORTED;
+               return FEEDBACK_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE System Error
        else if (err == -ECOMM || err == -EACCES)
-               return FEEDBACK_ERROR_PERMISSION_DENIED;
+               return FEEDBACK_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE System Error
        else if (err < 0) {
-               _E("fail to invoke is_supported() : pattern(%s)", profile->str_pattern[pattern]);
+               _E("fail to invoke is_supported() : pattern(%s)", profile->str_pattern[pattern]); //LCOV_EXCL_LINE
                return FEEDBACK_ERROR_OPERATION_FAILED;
        }
 
@@ -275,6 +275,7 @@ API int feedback_is_supported_pattern(feedback_type_e type, feedback_pattern_e p
        return FEEDBACK_ERROR_NONE;
 }
 
+//LCOV_EXCL_START Internal APIs. TODO Will make iUTC
 /* Internal APIs */
 API int feedback_play_type_by_name(char *type, char *pattern)
 {
@@ -375,3 +376,4 @@ API int feedback_set_resource_path(feedback_type_e type, feedback_pattern_e patt
 
        return FEEDBACK_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
index ce25289..6267330 100644 (file)
@@ -73,7 +73,7 @@ static int config_parse(const char *file_name,
        /* open conf file */
        f = fopen(file_name, "r");
        if (!f) {
-               _E("Failed to open file %s", file_name);
+               _E("Failed to open file %s", file_name); //LCOV_EXCL_LINE
                ret = -EIO;
                goto error;
        }
@@ -133,7 +133,7 @@ static int config_parse(const char *file_name,
 error:
        if (f)
                fclose(f);
-       _E("Failed to read %s:%d!", file_name, lineno);
+       _E("Failed to read %s:%d!", file_name, lineno); //LCOV_EXCL_LINE
        return ret;
 }
 
@@ -162,7 +162,7 @@ static int load_config(struct parse_result *result, void *user_data)
 
                info->data[i].origin = strdup(value);
                if (!info->data[i].origin)
-                       _E("fail to copy %s sound data",
+                       _E("fail to copy %s sound data", //LCOV_EXCL_LINE
                                        profile->str_pattern[i]);
                break;
        }
@@ -181,13 +181,13 @@ int feedback_load_config(const char *path,
        info->data = calloc(1,
                        sizeof(struct feedback_data) * profile->max_pattern);
        if (!info->data) {
-               _E("fail to allocate %s data", path);
-               return -ENOMEM;
+               _E("fail to allocate %s data", path); //LCOV_EXCL_LINE
+               return -ENOMEM; //LCOV_EXCL_LINE System Error
        }
 
        ret = config_parse(path, load_config, info);
        if (ret < 0)
-               _E("Failed to load %s, %d Use default value!",
+               _E("Failed to load %s, %d Use default value!", //LCOV_EXCL_LINE
                                path, ret);
 
        return ret;
index 6cb858e..131a22c 100644 (file)
@@ -79,6 +79,7 @@ inline int is_keytone_sndstatus(void)
        return keytone_sndstatus;
 }
 
+//LCOV_EXCL_START Not called Callback
 static void feedback_touch_sndstatus_cb(keynode_t *key, void* data)
 {
        touch_sndstatus = vconf_keynode_get_bool(key);
@@ -88,6 +89,7 @@ static void feedback_keytone_sndstatus_cb(keynode_t *key, void* data)
 {
        keytone_sndstatus = vconf_keynode_get_bool(key);
 }
+//LCOV_EXCL_STOP
 
 static void sound_init(void)
 {
@@ -96,13 +98,13 @@ static void sound_init(void)
 
        /* check sound status */
        if (vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &touch_sndstatus) < 0)
-               _W("VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL ==> FAIL!!");
+               _W("VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL ==> FAIL!!"); //LCOV_EXCL_LINE
 
        if (vconf_get_bool(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, &keytone_sndstatus) < 0)
-               _W("VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL ==> FAIL!!");
+               _W("VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL ==> FAIL!!"); //LCOV_EXCL_LINE
 
        if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sndstatus) < 0) {
-               _D("fail to get sound status, will work as turning off");
+               _D("fail to get sound status, will work as turning off"); //LCOV_EXCL_LINE
                sndstatus = 0;
        }
 
@@ -129,19 +131,19 @@ static int sound_play(feedback_pattern_e pattern)
        int level;
 
        if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sndstatus) < 0) {
-               _D("fail to get sound status, will work as turning off");
+               _D("fail to get sound status, will work as turning off"); //LCOV_EXCL_LINE
                sndstatus = 0;
        }
 
        if (sndstatus == 0 && profile->get_always_alert_case &&
            !profile->get_always_alert_case(FEEDBACK_TYPE_SOUND, pattern)) {
-               _D("Sound condition is OFF (sndstatus : %d)", sndstatus);
+               _D("Sound condition is OFF (sndstatus : %d)", sndstatus); //LCOV_EXCL_LINE
                return 0;
        }
 
        if (sndstatus && profile->get_always_off_case &&
            profile->get_always_off_case(FEEDBACK_TYPE_SOUND, pattern)) {
-               _D("Sound always off condition");
+               _D("Sound always off condition"); //LCOV_EXCL_LINE
                return 0;
        }
 
@@ -164,7 +166,7 @@ static int sound_play(feedback_pattern_e pattern)
                        _D("Play success! SND filename is %s", path);
                        return 0;
                }
-               _E("mm_sound_play_keysound() returned error(%d)", ret);
+               _E("mm_sound_play_keysound() returned error(%d)", ret); //LCOV_EXCL_LINE
        } while (retry--);
 
        return -EPERM;
@@ -177,7 +179,7 @@ static int sound_is_supported(feedback_pattern_e pattern, bool *supported)
        bool ret = true;
 
        if (!supported) {
-               _E("Invalid parameter : supported(NULL)");
+               _E("Invalid parameter : supported(NULL)"); //LCOV_EXCL_LINE
                return -EINVAL;
        }
 
@@ -192,6 +194,7 @@ static int sound_is_supported(feedback_pattern_e pattern, bool *supported)
        return 0;
 }
 
+//LCOV_EXCL_START Not used function-Internal APIs TODO Will make iUTC
 static int sound_get_path(feedback_pattern_e pattern, char *buf, unsigned int buflen)
 {
        char *cur_path;
@@ -239,6 +242,7 @@ static int sound_set_path(feedback_pattern_e pattern, char *path)
                        profile->str_pattern[pattern], path);
        return 0;
 }
+//LCOV_EXCL_STOP
 
 static const struct device_ops sound_device_ops = {
        .type = FEEDBACK_TYPE_SOUND,
index 19fb59e..1d74340 100644 (file)
@@ -116,37 +116,6 @@ static int haptic_close(unsigned int handle)
                        "u", arr);
 }
 
-static int haptic_vibrate_buffer(unsigned int handle,
-                                                               const unsigned char *buffer,
-                                                               int size,
-                                                               int iteration,
-                                                               int feedback,
-                                                               int priority)
-{
-       char *arr[6];
-       char buf_handle[32];
-       char buf_iteration[32];
-       char buf_feedback[32];
-       char buf_priority[32];
-       struct dbus_byte bytes;
-
-       snprintf(buf_handle, sizeof(buf_handle), "%u", handle);
-       arr[0] = buf_handle;
-       bytes.size = size;
-       bytes.data = buffer;
-       arr[2] = (char *)&bytes;
-       snprintf(buf_iteration, sizeof(buf_iteration), "%d", iteration);
-       arr[3] = buf_iteration;
-       snprintf(buf_feedback, sizeof(buf_feedback), "%d", feedback);
-       arr[4] = buf_feedback;
-       snprintf(buf_priority, sizeof(buf_priority), "%d", priority);
-       arr[5] = buf_priority;
-
-       return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_HAPTIC,
-                       DEVICED_INTERFACE_HAPTIC, METHOD_VIBRATE_BUFFER,
-                       "uayiii", arr);
-}
-
 static int haptic_vibrate_monotone(unsigned int handle,
                                                                int duration,
                                                                int feedback,
@@ -185,53 +154,6 @@ static int haptic_vibrate_stop(unsigned int handle)
                        "u", arr);
 }
 
-static unsigned char *convert_file_to_buffer(const char *file_name, int *size)
-{
-       FILE *pf;
-       long file_size;
-       unsigned char *pdata = NULL;
-
-       if (!file_name)
-               return NULL;
-
-       /* Get File Stream Pointer */
-       pf = fopen(file_name, "rb");
-       if (!pf) {
-               _E("fopen failed : %d", errno);
-               return NULL;
-       }
-
-       if (fseek(pf, 0, SEEK_END))
-               goto error;
-
-       file_size = ftell(pf);
-       if (fseek(pf, 0, SEEK_SET))
-               goto error;
-
-       if (file_size < 0)
-               goto error;
-
-       pdata = (unsigned char *)malloc(file_size);
-       if (!pdata)
-               goto error;
-
-       if (fread(pdata, 1, file_size, pf) != file_size)
-               goto err_free;
-
-       fclose(pf);
-       *size = file_size;
-       return pdata;
-
-err_free:
-       free(pdata);
-
-error:
-       fclose(pf);
-
-       _E("failed to convert file to buffer (%d)", errno);
-       return NULL;
-}
-
 static int get_priority(feedback_pattern_e pattern)
 {
        if (pattern >= FEEDBACK_PATTERN_TAP && pattern <= FEEDBACK_PATTERN_HW_HOLD)
@@ -262,14 +184,14 @@ static void vibrator_init(void)
        /* Vibration Init */
        ret = haptic_open();
        if (ret == -EACCES || ret == -ECOMM || ret == -EPERM) {
-               _E("haptic_open ==> FAIL!! : %d", ret);
-               v_handle = -EACCES;
-               return;
+               _E("haptic_open ==> FAIL!! : %d", ret); //LCOV_EXCL_LINE
+               v_handle = -EACCES; //LCOV_EXCL_LINE System Error
+               return; //LCOV_EXCL_LINE System Error
        }
        if (ret < 0) {
-               _E("haptic_open ==> FAIL!! : %d", ret);
-               v_handle = -ENOTSUP;
-               return;
+               _E("haptic_open ==> FAIL!! : %d", ret); //LCOV_EXCL_LINE
+               v_handle = -ENOTSUP; //LCOV_EXCL_LINE System Error
+               return; //LCOV_EXCL_LINE System Error
        }
 
        /* Set vibration handle */
@@ -286,7 +208,7 @@ static void vibrator_exit(void)
        if (v_handle > 0) {
                ret = haptic_close(v_handle);
                if (ret < 0)
-                       _E("haptic_close is failed : %d", ret);
+                       _E("haptic_close is failed : %d", ret); //LCOV_EXCL_LINE
                v_handle = 0;
        }
 
@@ -297,7 +219,6 @@ static void vibrator_exit(void)
 static int vibrator_play(feedback_pattern_e pattern)
 {
        struct stat buf;
-       char *data;
        unsigned char *pbuf;
        int size;
        int ret;
@@ -305,29 +226,29 @@ static int vibrator_play(feedback_pattern_e pattern)
        int duration;
 
        if (!v_handle) {
-               _E("Not initialize");
+               _E("Not initialize"); //LCOV_EXCL_LINE
                return -EPERM;
        }
 
        if (v_handle == -ENOTSUP || v_handle == -EACCES) {
-               _E("Not supported vibration");
-               return v_handle;
+               _E("Not supported vibration"); //LCOV_EXCL_LINE
+               return v_handle; //LCOV_EXCL_LINE System Error
        }
 
        if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) < 0) {
-               _D("fail to get vibration status, will work as turning off");
+               _D("fail to get vibration status, will work as turning off"); //LCOV_EXCL_LINE
                vibstatus = 0;
        }
 
        if (vibstatus == 0 && profile->get_always_alert_case &&
            !profile->get_always_alert_case(FEEDBACK_TYPE_VIBRATION, pattern))  {
-               _D("Vibration condition is OFF (vibstatus : %d)", vibstatus);
+               _D("Vibration condition is OFF (vibstatus : %d)", vibstatus); //LCOV_EXCL_LINE
                return 0;
        }
 
        if (vibstatus && profile->get_always_off_case &&
            profile->get_always_off_case(FEEDBACK_TYPE_VIBRATION, pattern)) {
-               _D("Vibration always off condition");
+               _D("Vibration always off condition"); //LCOV_EXCL_LINE
                return 0;
        }
 
@@ -336,39 +257,19 @@ static int vibrator_play(feedback_pattern_e pattern)
        else
                level = DEFAULT_VIB_LEVEL * HAPTIC_FEEDBACK_STEP;
 
-       /* get vibration data */
-       data = get_data(pattern);
-       if (!data) {
-               _E("Not supported vibration pattern");
-               return -ENOTSUP;
-       }
-
        /* if it has a file path */
-       if (!stat(data, &buf)) {
-               pbuf = convert_file_to_buffer(data, &size);
-               if (!pbuf) {
-                       _E("fail to convert file to buffer");
-                       return -EPERM;
-               }
-
-               ret = haptic_vibrate_buffer(v_handle, pbuf, size,
-                               HAPTIC_ITERATION_ONCE,
-                               level, get_priority(pattern));
-               free(pbuf);
-       } else {
-               duration = get_duration(pattern);
-               ret = haptic_vibrate_monotone(v_handle, duration,
-                               level, get_priority(pattern));
-       }
+       duration = get_duration(pattern);
+       ret = haptic_vibrate_monotone(v_handle, duration,
+                       level, get_priority(pattern));
 
        if (ret < 0) {
-               _E("fail to play vibration");
+               _E("fail to play vibration"); //LCOV_EXCL_LINE
                if (ret == -ECOMM)
-                       return ret;
+                       return ret; //LCOV_EXCL_LINE System Error
                return -EPERM;
        }
 
-       _D("Play success! Data is %s", data);
+       _D("Play success! Data is %d", pattern);
        return 0;
 }
 
@@ -377,21 +278,21 @@ static int vibrator_stop(void)
        int ret;
 
        if (!v_handle) {
-               _E("Not initialize");
+               _E("Not initialize"); //LCOV_EXCL_LINE
                return -EPERM;
        }
 
        if (v_handle == -ENOTSUP || v_handle == -EACCES) {
-               _E("Not supported vibration");
-               return v_handle;
+               _E("Not supported vibration"); //LCOV_EXCL_LINE
+               return v_handle; //LCOV_EXCL_LINE System Error
        }
 
        /* stop haptic device */
        ret = haptic_vibrate_stop(v_handle);
        if (ret < 0) {
-               _E("haptic_vibrate_stop is failed");
+               _E("haptic_vibrate_stop is failed"); //LCOV_EXCL_LINE
                if (ret == -ECOMM)
-                       return ret;
+                       return ret; //LCOV_EXCL_LINE System Error
                return -EPERM;
        }
 
@@ -404,18 +305,18 @@ static int vibrator_is_supported(int pattern, bool *supported)
        bool ret = true;
 
        if (!supported) {
-               _E("Invalid parameter : supported(NULL)");
+               _E("Invalid parameter : supported(NULL)"); //LCOV_EXCL_LINE
                return -EINVAL;
        }
 
        if (!v_handle) {
-               _E("Not initialize");
+               _E("Not initialize"); //LCOV_EXCL_LINE
                return -EPERM;
        }
 
        if (v_handle == -ENOTSUP || v_handle == -EACCES) {
-               _E("Not supported vibration");
-               *supported = false;
+               _E("Not supported vibration"); //LCOV_EXCL_LINE
+               *supported = false; //LCOV_EXCL_LINE System Error
                return v_handle;
        }
 
@@ -430,6 +331,7 @@ static int vibrator_is_supported(int pattern, bool *supported)
        return 0;
 }
 
+//LCOV_EXCL_START Not used function-Internal APIs TODO Will make iUTC
 static int vibrator_get_path(feedback_pattern_e pattern, char *buf, unsigned int buflen)
 {
        char *data;
@@ -485,6 +387,7 @@ static int vibrator_set_path(feedback_pattern_e pattern, char *path)
                        profile->str_pattern[pattern], path);
        return 0;
 }
+//LCOV_EXCL_STOP
 
 static const struct device_ops vibrator_device_ops = {
        .type = FEEDBACK_TYPE_VIBRATION,