From 0c309894e66a1309dc616247c4056d121939b365 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 12 Oct 2017 12:26:03 +0900 Subject: [PATCH] Exclude some lines from lcov Change-Id: I8a5e34a36051cc139e7339a623f3b76b33d78cb5 Signed-off-by: Hwankyu Jhun --- src/service_app_main.c | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/service_app_main.c b/src/service_app_main.c index a9158bc..8db63c2 100644 --- a/src/service_app_main.c +++ b/src/service_app_main.c @@ -102,23 +102,29 @@ static struct job_s *__create_job(int job_status, const char *job_id, job = calloc(1, sizeof(struct job_s)); if (job == NULL) { + /* LCOV_EXCL_START */ LOGE("Out of memory"); return NULL; + /* LCOV_EXCL_STOP */ } job->job_id = strdup(job_id); if (job->job_id == NULL) { + /* LCOV_EXCL_START */ LOGE("Out of memory"); free(job); return NULL; + /* LCOV_EXCL_STOP */ } job->job_data = bundle_dup(job_data); if (job->job_data == NULL) { + /* LCOV_EXCL_START */ LOGE("Out of memory"); free(job->job_id); free(job); return NULL; + /* LCOV_EXCL_STOP */ } job->job_status = job_status; @@ -134,9 +140,9 @@ static void __destroy_job(gpointer data) return; if (job->idler) - g_source_remove(job->idler); + g_source_remove(job->idler); /* LCOV_EXCL_LINE */ if (job->timer) - g_source_remove(job->timer); + g_source_remove(job->timer); /* LCOV_EXCL_LINE */ if (job->job_data) bundle_free(job->job_data); if (job->job_id) @@ -144,6 +150,7 @@ static void __destroy_job(gpointer data) free(job); } +/* LCOV_EXCL_START */ static gboolean __pending_job_timeout_handler(gpointer data) { struct job_s *job = (struct job_s *)data; @@ -155,17 +162,22 @@ static gboolean __pending_job_timeout_handler(gpointer data) return G_SOURCE_REMOVE; } +/* LCOV_EXCL_STOP */ static void __job_finish(void) { if (__context.running_jobs) { + /* LCOV_EXCL_START */ g_list_free_full(__context.running_jobs, __destroy_job); __context.running_jobs = NULL; + /* LCOV_EXCL_STOP */ } if (__context.pending_jobs) { + /* LCOV_EXCL_START */ g_list_free_full(__context.pending_jobs, __destroy_job); __context.pending_jobs = NULL; + /* LCOV_EXCL_STOP */ } if (__context.job_handlers) { @@ -283,7 +295,7 @@ EXPORT_API int service_app_main_ext(int argc, char **argv, service_app_lifecycle return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "service_app_create_cb() callback must be registered"); if (__app_state != APP_STATE_NOT_RUNNING) - return __on_error(APP_ERROR_ALREADY_RUNNING, __FUNCTION__, NULL); + return __on_error(APP_ERROR_ALREADY_RUNNING, __FUNCTION__, NULL); /* LCOV_EXCL_LINE */ /* override methods */ ops.create = __service_app_create; @@ -300,8 +312,10 @@ EXPORT_API int service_app_main_ext(int argc, char **argv, service_app_lifecycle __app_state = APP_STATE_CREATING; ret = appcore_base_init(ops, argc, argv, NULL); if (ret < 0) { + /* LCOV_EXCL_START */ __app_state = APP_STATE_NOT_RUNNING; return __on_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL); + /* LCOV_EXCL_STOP */ } appcore_base_fini(); @@ -354,7 +368,7 @@ EXPORT_API int service_app_add_event_handler(app_event_handler_h *event_handler, handler = calloc(1, sizeof(struct app_event_handler)); if (!handler) - return __on_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, "insufficient memory"); + return __on_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, "insufficient memory"); /* LCOV_EXCL_LINE */ handler->type = event_type; handler->cb = callback; @@ -378,13 +392,13 @@ EXPORT_API int service_app_remove_event_handler(app_event_handler_h event_handle if (type < APP_EVENT_LOW_MEMORY || type > APP_EVENT_SUSPENDED_STATE_CHANGED || type == APP_EVENT_DEVICE_ORIENTATION_CHANGED) - return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); /* LCOV_EXCL_LINE */ ret = appcore_base_remove_event(event_handler->raw); free(event_handler); if (ret < 0) - return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); /* LCOV_EXCL_LINE */ return APP_ERROR_NONE; } @@ -447,6 +461,7 @@ static void __flush_pending_job(const char *job_id) iter = __context.pending_jobs; while (iter) { + /* LCOV_EXCL_START */ job = (struct job_s *)iter->data; iter = iter->next; if (strcmp(job->job_id, job_id) == 0) { @@ -462,6 +477,7 @@ static void __flush_pending_job(const char *job_id) __context.running_jobs = g_list_append( __context.running_jobs, job); } + /* LCOV_EXCL_STOP */ } } @@ -489,15 +505,19 @@ static struct service_app_job_s *__create_job_handler(const char *job_id, handle = calloc(1, sizeof(struct service_app_job_s)); if (handle == NULL) { + /* LCOV_EXCL_START */ LOGE("Out of memory"); return NULL; + /* LCOV_EXCL_STOP */ } handle->job_id = strdup(job_id); if (handle->job_id == NULL) { + /* LCOV_EXCL_START */ LOGE("Out of memory"); free(handle); return NULL; + /* LCOV_EXCL_STOP */ } handle->callback = callback; @@ -524,8 +544,10 @@ EXPORT_API service_app_job_h service_app_add_job_handler(const char *job_id, struct service_app_job_s *handle; if (job_id == NULL || callback == NULL) { + /* LCOV_EXCL_START */ LOGE("Invalid parameter"); return NULL; + /* LCOV_EXCL_STOP */ } handle = __create_job_handler(job_id, callback, user_data); @@ -543,8 +565,10 @@ EXPORT_API int service_app_remove_job_handler(service_app_job_h handle) { if (handle == NULL || g_list_index(__context.job_handlers, handle) < 0) { + /* LCOV_EXCL_START */ return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + /* LCOV_EXCL_STOP */ } __context.job_handlers = g_list_remove(__context.job_handlers, handle); @@ -562,19 +586,23 @@ EXPORT_API int service_app_job_raise(int job_status, const char *job_id, if (job_status < SERVICE_APP_JOB_STATUS_START || job_status > SERVICE_APP_JOB_STATUS_STOP || job_id == NULL || job_data == NULL) { + /* LCOV_EXCL_START */ return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + /* LCOV_EXCL_STOP */ } job = __create_job(job_status, job_id, job_data); if (job == NULL) - return __on_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return __on_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); /* LCOV_EXCL_LINE */ if (!__exist_job_handler(job_id)) { + /* LCOV_EXCL_START */ job->timer = g_timeout_add(5000, __pending_job_timeout_handler, job); __context.pending_jobs = g_list_append(__context.pending_jobs, job); + /* LCOV_EXCL_STOP */ } else { job->idler = g_idle_add(__handle_job, job); __context.running_jobs = g_list_append(__context.running_jobs, @@ -591,6 +619,7 @@ static void __remove_running_job(const char *job_id) iter = __context.running_jobs; while (iter) { + /* LCOV_EXCL_START */ job = (struct job_s *)iter->data; iter = iter->next; if (strcmp(job->job_id, job_id) == 0) { @@ -598,6 +627,7 @@ static void __remove_running_job(const char *job_id) __context.running_jobs, job); __destroy_job(job); } + /* LCOV_EXCL_STOP */ } } @@ -606,16 +636,20 @@ EXPORT_API int service_app_job_finished(const char *job_id) int r; if (job_id == NULL) { + /* LCOV_EXCL_START */ return __on_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + /* LCOV_EXCL_STOP */ } __remove_running_job(job_id); r = aul_job_scheduler_update_job_status(job_id, JOB_STATUS_FINISHED); if (r != AUL_R_OK) { + /* LCOV_EXCL_START */ return __on_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL); + /* LCOV_EXCL_STOP */ } return APP_ERROR_NONE; -- 2.7.4