From 43d75b16fad199fe5e7912c976f465f587561f76 Mon Sep 17 00:00:00 2001 From: "chleun.moon" Date: Fri, 1 Apr 2016 10:04:17 +0900 Subject: [PATCH] Added comments to exclude coverage Change-Id: I1e6b0dcd2363fdd31683d56c7b4387cf82c3a66f Signed-off-by: cheoleun --- CMakeLists.txt | 2 +- packaging/capi-network-nsd.spec | 3 +- src/dns-sd/dns-sd-util.h | 12 +- src/dns-sd/dns-sd.c | 257 +++++++++++++++++++++------------------- src/ssdp/ssdp-util.h | 12 +- src/ssdp/ssdp.c | 63 +++++----- 6 files changed, 186 insertions(+), 163 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb5b63e..0cb69ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,7 @@ FOREACH(flag ${NSD_DEPS_CFLAGS}) ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fprofile-arcs -ftest-coverage") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2 -g") diff --git a/packaging/capi-network-nsd.spec b/packaging/capi-network-nsd.spec index 884793a..980f3d2 100644 --- a/packaging/capi-network-nsd.spec +++ b/packaging/capi-network-nsd.spec @@ -62,7 +62,8 @@ cp -a %{SOURCE1004} . %build %if 0%{?sec_build_binary_debug_enable} export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE -fprofile-arcs -ftest-coverage" +export LDFLAGS = "-lgcov" %endif diff --git a/src/dns-sd/dns-sd-util.h b/src/dns-sd/dns-sd-util.h index c673a7c..37bfc25 100644 --- a/src/dns-sd/dns-sd-util.h +++ b/src/dns-sd/dns-sd-util.h @@ -24,13 +24,13 @@ #undef LOG_TAG #define LOG_TAG "CAPI_NETWORK_DNSSD" -#define DNSSD_LOGD(format, args...) LOGD(format, ##args) -#define DNSSD_LOGI(format, args...) LOGI(format, ##args) -#define DNSSD_LOGW(format, args...) LOGW(format, ##args) -#define DNSSD_LOGE(format, args...) LOGE(format, ##args) +#define DNSSD_LOGD(format, args...) LOGD(format, ##args) //LCOV_EXCL_LINE +#define DNSSD_LOGI(format, args...) LOGI(format, ##args) //LCOV_EXCL_LINE +#define DNSSD_LOGW(format, args...) LOGW(format, ##args) //LCOV_EXCL_LINE +#define DNSSD_LOGE(format, args...) LOGE(format, ##args) //LCOV_EXCL_LINE -#define __DNSSD_LOG_FUNC_ENTER__ LOGD("Enter") -#define __DNSSD_LOG_FUNC_EXIT__ LOGD("Quit") +#define __DNSSD_LOG_FUNC_ENTER__ LOGD("Enter") //LCOV_EXCL_LINE +#define __DNSSD_LOG_FUNC_EXIT__ LOGD("Quit") //LCOV_EXCL_LINE #define NETWORK_SERVICE_DISCOVERY_FEATURE "http://tizen.org/feature/network.service_discovery.dnssd" diff --git a/src/dns-sd/dns-sd.c b/src/dns-sd/dns-sd.c index 00e317e..cba912b 100644 --- a/src/dns-sd/dns-sd.c +++ b/src/dns-sd/dns-sd.c @@ -42,21 +42,21 @@ static const char *dnssd_error_to_string(dnssd_error_e error) case DNSSD_ERROR_NONE: return "DNSSD_ERROR_NONE"; case DNSSD_ERROR_OUT_OF_MEMORY: - return "DNSSD_ERROR_OUT_OF_MEMORY"; + return "DNSSD_ERROR_OUT_OF_MEMORY"; //LCOV_EXCL_LINE case DNSSD_ERROR_INVALID_PARAMETER: - return "DNSSD_ERROR_INVALID_PARAMETER"; + return "DNSSD_ERROR_INVALID_PARAMETER"; //LCOV_EXCL_LINE case DNSSD_ERROR_NOT_SUPPORTED: - return "DNSSD_ERROR_NOT_SUPPORTED"; + return "DNSSD_ERROR_NOT_SUPPORTED"; //LCOV_EXCL_LINE case DNSSD_ERROR_NOT_INITIALIZED: - return "DNSSD_ERROR_NOT_INITIALIZED"; + return "DNSSD_ERROR_NOT_INITIALIZED"; //LCOV_EXCL_LINE case DNSSD_ERROR_ALREADY_REGISTERED: - return "DNSSD_ERROR_ALREADY_REGISTERED"; + return "DNSSD_ERROR_ALREADY_REGISTERED";//LCOV_EXCL_LINE case DNSSD_ERROR_NAME_CONFLICT: - return "DNSSD_ERROR_NAME_CONFLICT"; + return "DNSSD_ERROR_NAME_CONFLICT"; //LCOV_EXCL_LINE case DNSSD_ERROR_SERVICE_NOT_RUNNING: - return "DNSSD_ERROR_SERVICE_NOT_RUNNING"; + return "DNSSD_ERROR_SERVICE_NOT_RUNNING";//LCOV_EXCL_LINE case DNSSD_ERROR_OPERATION_FAILED: - return "DNSSD_ERROR_OPERATION_FAILED"; + return "DNSSD_ERROR_OPERATION_FAILED"; //LCOV_EXCL_LINE default: return "UNSUPPORTED_ERROR"; } @@ -74,9 +74,9 @@ int dnssd_initialize(void) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == true) { - DNSSD_LOGE("Already initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_INVALID_OPERATION; + DNSSD_LOGE("Already initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE } g_is_init = true; @@ -135,9 +135,9 @@ int dnssd_create_local_service(const char *service_type, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if(dnssd_service == NULL || service_type == NULL || @@ -149,9 +149,9 @@ int dnssd_create_local_service(const char *service_type, local_handle = (dnssd_handle_s *)g_try_malloc0(REG_SIZE); if (local_handle == NULL) { - DNSSD_LOGE("Failed to Allocate Memory"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_OUT_OF_MEMORY; + DNSSD_LOGE("Failed to Allocate Memory"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } handler = (unsigned int)local_handle & 0xffffffff; @@ -180,9 +180,9 @@ int dnssd_destroy_local_service(dnssd_service_h dnssd_service) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(dnssd_service); @@ -221,9 +221,9 @@ int dnssd_service_set_name(dnssd_service_h local_service, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (service_name == NULL) { @@ -264,9 +264,9 @@ int dnssd_service_set_port(dnssd_service_h local_service, int port) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (port < 0 || port > 65535) { @@ -283,9 +283,9 @@ int dnssd_service_set_port(dnssd_service_h local_service, int port) } if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; + DNSSD_LOGD("DNSSD service is not a local service"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_SERVICE_NOT_FOUND; //LCOV_EXCL_LINE } reg = GET_REG_DATA_P(local_handle); @@ -309,9 +309,9 @@ int dnssd_service_add_txt_record(dnssd_service_h local_service, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(local_service); @@ -334,7 +334,7 @@ int dnssd_service_add_txt_record(dnssd_service_h local_service, } if (length == 0 || value == NULL) - DNSSD_LOGD("Value size is 0 or NULL value passed"); + DNSSD_LOGD("Value size is 0 or NULL value passed"); //LCOV_EXCL_LINE reg = GET_REG_DATA_P(local_handle); txt_record = &(reg->txt_ref); @@ -343,8 +343,8 @@ int dnssd_service_add_txt_record(dnssd_service_h local_service, ret = TXTRecordSetValue(txt_record, key, length, value); if (ret != DNSSD_ERROR_NONE) { - DNSSD_LOGE("Failed to add value to key, error[%s]", - dnssd_error_to_string(ret)); + DNSSD_LOGE("Failed to add value to key, error[%s]", //LCOV_EXCL_LINE + dnssd_error_to_string(ret)); //LCOV_EXCL_LINE __DNSSD_LOG_FUNC_EXIT__; return ret; } else { @@ -368,9 +368,9 @@ int dnssd_service_remove_txt_record(dnssd_service_h local_service, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (key == NULL) { @@ -430,9 +430,9 @@ int dnssd_service_set_record(dnssd_service_h local_service, unsigned short type, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(local_service); @@ -458,15 +458,15 @@ int dnssd_service_set_record(dnssd_service_h local_service, unsigned short type, ret = DNSServiceAddRecord(sd_ref, &(reg->record_ref), local_handle->flags, type, length, data, 0); } else { - DNSSD_LOGD("Updating DNS Service Record"); - ret = DNSServiceUpdateRecord(sd_ref, record_client, - local_handle->flags, length, data, 0); + DNSSD_LOGD("Updating DNS Service Record"); //LCOV_EXCL_LINE + ret = DNSServiceUpdateRecord(sd_ref, record_client, //LCOV_EXCL_LINE + local_handle->flags, length, data, 0); //LCOV_EXCL_LINE } if (ret < 0) { - DNSSD_LOGE("Failed to Add Record for DNS Service, error[%s]", - dnssd_error_to_string(ret)); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_OPERATION_FAILED; + DNSSD_LOGE("Failed to Add Record for DNS Service, error[%s]", //LCOV_EXCL_LINE + dnssd_error_to_string(ret)); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } DNSSD_LOGD("Successfully added record for DNS Service"); @@ -488,9 +488,9 @@ int dnssd_service_unset_record(dnssd_service_h local_service, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(local_service); @@ -519,10 +519,10 @@ int dnssd_service_unset_record(dnssd_service_h local_service, ret = DNSServiceRemoveRecord(sd_ref, record_client, local_handle->flags); if(ret < 0) { - DNSSD_LOGE("Failed to Remove Record for DNS Service, error[%s]", - dnssd_error_to_string(ret)); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_OPERATION_FAILED; + DNSSD_LOGE("Failed to Remove Record for DNS Service, error[%s]", //LCOV_EXCL_LINE + dnssd_error_to_string(ret)); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } reg->record_ref = NULL; @@ -546,9 +546,9 @@ static void __dnssd_register_reply_cb(DNSServiceRef sd_ref, unsigned int flags, DNSSD_LOGD("Received Registration Reply"); if (error_code != DNSSD_ERROR_NONE) - DNSSD_LOGE("Failed to register, error code %d -> %s", - error_code, - dnssd_error_to_string(error_code)); + DNSSD_LOGE("Failed to register, error code %d -> %s", //LCOV_EXCL_LINE + error_code, //LCOV_EXCL_LINE + dnssd_error_to_string(error_code)); //LCOV_EXCL_LINE for (list = dnssd_handle_list; list; list = list->next) { dnssd_handle = (dnssd_handle_s *) list->data; @@ -588,9 +588,9 @@ int dnssd_register_local_service(dnssd_service_h local_service, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(local_service); @@ -607,17 +607,17 @@ int dnssd_register_local_service(dnssd_service_h local_service, } if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; + DNSSD_LOGD("DNSSD service is not a local service"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_SERVICE_NOT_FOUND; //LCOV_EXCL_LINE } reg = GET_REG_DATA_P(local_handle); sd_ref = &(local_handle->sd_ref); if (reg->service_name == NULL) { - DNSSD_LOGD("No Service Name Provided"); - reg->service_name = g_strdup(""); + DNSSD_LOGD("No Service Name Provided"); //LCOV_EXCL_LINE + reg->service_name = g_strdup(""); //LCOV_EXCL_LINE } else DNSSD_LOGD("Service Name is %s", reg->service_name); @@ -630,10 +630,10 @@ int dnssd_register_local_service(dnssd_service_h local_service, NULL, reg->port, 1, "", __dnssd_register_reply_cb, NULL); if(ret < 0) { - DNSSD_LOGE("Failed to register for dns service, error[%s]", - dnssd_error_to_string(ret)); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_OPERATION_FAILED; + DNSSD_LOGE("Failed to register for dns service, error[%s]", //LCOV_EXCL_LINE + dnssd_error_to_string(ret)); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } reg->callback = register_cb; @@ -657,9 +657,9 @@ int dnssd_deregister_local_service(dnssd_service_h local_service) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(local_service); @@ -687,11 +687,11 @@ int dnssd_deregister_local_service(dnssd_service_h local_service) if (record_client) { ret = DNSServiceRemoveRecord(sd_ref, record_client, local_handle->flags); - if(ret < 0) - DNSSD_LOGE("Failed to Remove Record for DNS Service, " - "error[%s]", dnssd_error_to_string(ret)); - else - reg->record_ref = NULL; + if(ret < 0) //LCOV_EXCL_LINE + DNSSD_LOGE("Failed to Remove Record for DNS Service, " //LCOV_EXCL_LINE + "error[%s]", dnssd_error_to_string(ret)); //LCOV_EXCL_LINE + else //LCOV_EXCL_LINE + reg->record_ref = NULL; //LCOV_EXCL_LINE } DNSServiceRefDeallocate(sd_ref); @@ -700,6 +700,7 @@ int dnssd_deregister_local_service(dnssd_service_h local_service) return DNSSD_ERROR_NONE; } +//LCOV_EXCL_START static void __dnssd_getaddrinfo_reply_cb(DNSServiceRef sd_ref, unsigned int flags, unsigned int if_index, DNSServiceErrorType error_code, const char *host_name, @@ -765,7 +766,9 @@ static void __dnssd_getaddrinfo_reply_cb(DNSServiceRef sd_ref, } } +//LCOV_EXCL_STOP +//LCOV_EXCL_START static int __dnssd_getaddrinfo(dnssd_handle_s *dnssd_handle, unsigned int flags, unsigned int if_index, const char *host_name, const char *fullname, const char *txt_record, @@ -845,7 +848,9 @@ static int __dnssd_getaddrinfo(dnssd_handle_s *dnssd_handle, unsigned int flags, return DNSSD_ERROR_NONE; } +//LCOV_EXCL_STOP +//LCOV_EXCL_START static void __dnssd_resolve_reply_cb(DNSServiceRef sd_ref, unsigned int flags, unsigned int if_index, DNSServiceErrorType error_code, const char *fullname, const char *host_name, @@ -859,7 +864,9 @@ static void __dnssd_resolve_reply_cb(DNSServiceRef sd_ref, unsigned int flags, host_name, fullname, (const char *) txt_record, txt_len, port); } +//LCOV_EXCL_STOP +//LCOV_EXCL_START static int __dnssd_resolve_dns_service(dnssd_handle_s *dnssd_handle, unsigned int flags, unsigned int if_index, const char *service_name, const char *type, const char *domain) @@ -898,7 +905,9 @@ static int __dnssd_resolve_dns_service(dnssd_handle_s *dnssd_handle, __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; } +//LCOV_EXCL_STOP +//LCOV_EXCL_START static dnssd_handle_s *__dnssd_get_found_handle(dnssd_service_h browse_service, const char *service_name) { @@ -926,7 +935,9 @@ static dnssd_handle_s *__dnssd_get_found_handle(dnssd_service_h browse_service, __DNSSD_LOG_FUNC_EXIT__; return NULL; } +//LCOV_EXCL_STOP +//LCOV_EXCL_START static void __dnssd_broswe_reply_cb(DNSServiceRef sd_ref, unsigned int flags, unsigned int if_index, DNSServiceErrorType error_code, const char *service_name, const char *service_type, @@ -994,6 +1005,7 @@ static void __dnssd_broswe_reply_cb(DNSServiceRef sd_ref, unsigned int flags, } __DNSSD_LOG_FUNC_EXIT__; } +//LCOV_EXCL_STOP int dnssd_start_browsing_service(const char *service_type, dnssd_browser_h *dnssd_service, dnssd_found_cb found_cb, @@ -1009,9 +1021,9 @@ int dnssd_start_browsing_service(const char *service_type, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if(dnssd_service == NULL || service_type == NULL || @@ -1029,9 +1041,9 @@ int dnssd_start_browsing_service(const char *service_type, local_handle = (dnssd_handle_s *)g_try_malloc0(BROWSE_SIZE); if (local_handle == NULL) { - DNSSD_LOGE("Failed to Allocate Memory"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_OUT_OF_MEMORY; + DNSSD_LOGE("Failed to Allocate Memory"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } handler = (unsigned int)local_handle & 0xffffffff; @@ -1053,12 +1065,12 @@ int dnssd_start_browsing_service(const char *service_type, local_handle->domain, __dnssd_broswe_reply_cb, NULL); if(ret < 0) { - DNSSD_LOGE("Failed to browse for dns service, error[%s]", - dnssd_error_to_string(ret)); - g_free(local_handle->service_type); - g_free(local_handle); - __DNSSD_LOG_FUNC_EXIT__; - return ret; + DNSSD_LOGE("Failed to browse for dns service, error[%s]", //LCOV_EXCL_LINE + dnssd_error_to_string(ret)); //LCOV_EXCL_LINE + g_free(local_handle->service_type); //LCOV_EXCL_LINE + g_free(local_handle); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } browse->callback = found_cb; @@ -1084,6 +1096,7 @@ static void __dnssd_remove_found_service(gpointer data, gpointer user_data) if(found_handle->op_type != DNSSD_TYPE_FOUND) return; + //LCOV_EXCL_START found_data = GET_FOUND_DATA_P(found_handle); if(found_data->browse_handler != *handler) return; @@ -1102,6 +1115,7 @@ static void __dnssd_remove_found_service(gpointer data, gpointer user_data) __DNSSD_LOG_FUNC_EXIT__; return; + //LCOV_EXCL_STOP } int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service) @@ -1115,9 +1129,9 @@ int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(dnssd_service); @@ -1135,9 +1149,9 @@ int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service) sd_ref = local_handle->sd_ref; if(NULL == sd_ref) { - DNSSD_LOGE("Invalid DNS SD Client"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_INVALID_PARAMETER; + DNSSD_LOGE("Invalid DNS SD Client"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE } g_slist_foreach(dnssd_handle_list, (GFunc)__dnssd_remove_found_service, @@ -1145,6 +1159,7 @@ int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service) list = resolve_handle_list; while (list) { + //LCOV_EXCL_START resolve_data = list->data; list = list->next; @@ -1156,6 +1171,7 @@ int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service) g_free(resolve_data); } + //LCOV_EXCL_STOP } DNSServiceRefDeallocate(sd_ref); @@ -1174,9 +1190,9 @@ int dnssd_service_get_type(dnssd_service_h dnssd_service, char **service_type) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (service_type == NULL) { @@ -1207,9 +1223,9 @@ int dnssd_service_get_name(dnssd_service_h dnssd_service, char **service_name) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (service_name == NULL) { @@ -1226,15 +1242,15 @@ int dnssd_service_get_name(dnssd_service_h dnssd_service, char **service_name) } if(local_handle->op_type == DNSSD_TYPE_FOUND) { - dnssd_found_data_s *found = NULL; - found = GET_FOUND_DATA_P(local_handle); - *service_name = g_strdup(found->service_name); + dnssd_found_data_s *found = NULL; //LCOV_EXCL_LINE + found = GET_FOUND_DATA_P(local_handle); //LCOV_EXCL_LINE + *service_name = g_strdup(found->service_name); //LCOV_EXCL_LINE } else if(local_handle->op_type == DNSSD_TYPE_REGISTER) { dnssd_register_data_s *reg = NULL; reg = GET_REG_DATA_P(local_handle); *service_name = g_strdup(reg->service_name); } else { - *service_name = NULL; + *service_name = NULL; DNSSD_LOGD("Invalid DNS SD service"); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_INVALID_PARAMETER; @@ -1246,7 +1262,7 @@ int dnssd_service_get_name(dnssd_service_h dnssd_service, char **service_name) return DNSSD_ERROR_NONE; } - +//LCOV_EXCL_START int dnssd_service_get_ip(dnssd_service_h dnssd_service, char **ip_v4_address, char **ip_v6_address) { @@ -1302,6 +1318,7 @@ int dnssd_service_get_ip(dnssd_service_h dnssd_service, char **ip_v4_address, __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; } +//LCOV_EXCL_STOP int dnssd_service_get_port(dnssd_service_h dnssd_service, int *port) { @@ -1311,9 +1328,9 @@ int dnssd_service_get_port(dnssd_service_h dnssd_service, int *port) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (port == NULL) { @@ -1330,9 +1347,9 @@ int dnssd_service_get_port(dnssd_service_h dnssd_service, int *port) } if(local_handle->op_type == DNSSD_TYPE_FOUND) { - dnssd_found_data_s *found = NULL; - found = GET_FOUND_DATA_P(local_handle); - *port = found->port; + dnssd_found_data_s *found = NULL; //LCOV_EXCL_LINE + found = GET_FOUND_DATA_P(local_handle); //LCOV_EXCL_LINE + *port = found->port; //LCOV_EXCL_LINE } else if(local_handle->op_type == DNSSD_TYPE_REGISTER) { dnssd_register_data_s *reg = NULL; reg = GET_REG_DATA_P(local_handle); @@ -1359,9 +1376,9 @@ int dnssd_service_get_all_txt_record(dnssd_service_h dnssd_service, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; + DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } local_handle = __dnssd_check_handle_validity(dnssd_service); @@ -1379,11 +1396,11 @@ int dnssd_service_get_all_txt_record(dnssd_service_h dnssd_service, if(local_handle->op_type == DNSSD_TYPE_FOUND) { - dnssd_found_data_s *found = NULL; - found = GET_FOUND_DATA_P(local_handle); + dnssd_found_data_s *found = NULL; //LCOV_EXCL_LINE + found = GET_FOUND_DATA_P(local_handle); //LCOV_EXCL_LINE - *value = g_strdup(found->txt_record); - *length = found->txt_len; + *value = g_strdup(found->txt_record); //LCOV_EXCL_LINE + *length = found->txt_len; //LCOV_EXCL_LINE } else { dnssd_register_data_s *reg = NULL; diff --git a/src/ssdp/ssdp-util.h b/src/ssdp/ssdp-util.h index c0c3dcd..3a54117 100644 --- a/src/ssdp/ssdp-util.h +++ b/src/ssdp/ssdp-util.h @@ -24,13 +24,13 @@ #undef LOG_TAG #define LOG_TAG "CAPI_NETWORK_SSDP" -#define SSDP_LOGD(format, args...) LOGD(format, ##args) -#define SSDP_LOGI(format, args...) LOGI(format, ##args) -#define SSDP_LOGW(format, args...) LOGW(format, ##args) -#define SSDP_LOGE(format, args...) LOGE(format, ##args) +#define SSDP_LOGD(format, args...) LOGD(format, ##args) //LCOV_EXCL_LINE +#define SSDP_LOGI(format, args...) LOGI(format, ##args) //LCOV_EXCL_LINE +#define SSDP_LOGW(format, args...) LOGW(format, ##args) //LCOV_EXCL_LINE +#define SSDP_LOGE(format, args...) LOGE(format, ##args) //LCOV_EXCL_LINE -#define __SSDP_LOG_FUNC_ENTER__ LOGD("Enter") -#define __SSDP_LOG_FUNC_EXIT__ LOGD("Quit") +#define __SSDP_LOG_FUNC_ENTER__ LOGD("Enter") //LCOV_EXCL_LINE +#define __SSDP_LOG_FUNC_EXIT__ LOGD("Quit") //LCOV_EXCL_LINE #else /* USE_DLOG */ diff --git a/src/ssdp/ssdp.c b/src/ssdp/ssdp.c index cd78af8..d716e1b 100644 --- a/src/ssdp/ssdp.c +++ b/src/ssdp/ssdp.c @@ -90,6 +90,7 @@ static __thread GHashTable *g_found_ssdp_services = NULL; /** * free a local service */ +//LCOV_EXCL_START static void __g_list_free_service(gpointer data, gpointer user_data) { ssdp_service_s *service = NULL; @@ -97,13 +98,6 @@ static void __g_list_free_service(gpointer data, gpointer user_data) service = (ssdp_service_s *)data; if(service == NULL) return; - /* moon - if(service->resource_group != NULL && service->resource_id != 0) - gssdp_resource_group_remove_resource(service->resource_group, service->resource_id); - - if(service->resource_browser != NULL) - g_object_unref (service->resource_browser); - */ if(service->origin == SSDP_SERVICE_STATE_NOT_REGISTERED) SSDP_LOGE("Free not registered service"); else if(service->origin == SSDP_SERVICE_STATE_REGISTERED) @@ -118,10 +112,12 @@ static void __g_list_free_service(gpointer data, gpointer user_data) g_free(service->url); g_free(service); } +//LCOV_EXCL_STOP /** * free a remote service */ +//LCOV_EXCL_START static void __g_hash_free_service(gpointer key, gpointer value, gpointer user_data) { @@ -149,10 +145,12 @@ static void __g_hash_free_service(gpointer key, gpointer value, g_free(service->url); g_free(service); } +//LCOV_EXCL_STOP /** * remove remove services found by request of a browser (browser_id is passed to by user_data) */ +//LCOV_EXCL_START static void __g_hash_remove_related_services(gpointer key, gpointer value, gpointer user_data) { @@ -173,6 +171,7 @@ static void __g_hash_remove_related_services(gpointer key, gpointer value, g_free(service->url); g_free(service); } +//LCOV_EXCL_STOP static ssdp_service_s *__ssdp_find_local_service(GList *services, unsigned int handler) @@ -234,6 +233,7 @@ static ssdp_service_s *__ssdp_find_local_service_with_url(GList *services, return service; } +//LCOV_EXCL_START static void __g_hash_find_remote_service(gpointer key, gpointer value, gpointer user_data) { @@ -253,6 +253,7 @@ static void __g_hash_find_remote_service(gpointer key, gpointer value, return; } +//LCOV_EXCL_STOP static ssdp_service_s *__ssdp_find_remote_service(GHashTable *services, unsigned int handler) @@ -267,6 +268,7 @@ static ssdp_service_s *__ssdp_find_remote_service(GHashTable *services, return user_data.service; } +//LCOV_EXCL_START static void __ssdp_res_available_cb (GSSDPResourceBrowser *resource_browser, const char *usn, GList *urls, gpointer user_data) @@ -343,7 +345,9 @@ __ssdp_res_available_cb (GSSDPResourceBrowser *resource_browser, return; } +//LCOV_EXCL_STOP +//LCOV_EXCL_START static void __ssdp_res_unavailable_cb (GSSDPResourceBrowser *resource_browser, const char *usn, GList *urls, gpointer user_data) @@ -382,6 +386,7 @@ __ssdp_res_unavailable_cb (GSSDPResourceBrowser *resource_browser, __SSDP_LOG_FUNC_EXIT__; return; } +//LCOV_EXCL_STOP int ssdp_initialize() { @@ -401,7 +406,7 @@ int ssdp_initialize() if (gerror) { SSDP_LOGE("Error creating the GSSDP client: %s\n", gerror->message); - g_error_free(gerror); + g_error_free(gerror); //LCOV_EXCL_LINE __SSDP_LOG_FUNC_EXIT__; return SSDP_ERROR_OPERATION_FAILED; } @@ -458,7 +463,7 @@ int ssdp_create_local_service(const char *target, ssdp_service_h *ssdp_service) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (ssdp_service == NULL) { @@ -471,15 +476,15 @@ int ssdp_create_local_service(const char *target, ssdp_service_h *ssdp_service) if (!service) { SSDP_LOGE("Failed to get memory for gssdp service structure"); __SSDP_LOG_FUNC_EXIT__; - return SSDP_ERROR_OUT_OF_MEMORY; + return SSDP_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } service->target = g_strndup(target, strlen(target)); if (!service->target) { SSDP_LOGE("Failed to get memory for gssdp service type"); - g_free(service); + g_free(service); //LCOV_EXCL_LINE __SSDP_LOG_FUNC_EXIT__; - return SSDP_ERROR_OUT_OF_MEMORY; + return SSDP_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } *ssdp_service = (unsigned int)service & 0xFFFFFFFF; @@ -509,7 +514,7 @@ int ssdp_destroy_local_service(ssdp_service_h ssdp_service) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, ssdp_service); @@ -517,10 +522,10 @@ int ssdp_destroy_local_service(ssdp_service_h ssdp_service) return SSDP_ERROR_SERVICE_NOT_FOUND; if (service->resource_group != NULL) - service->resource_group = NULL; + service->resource_group = NULL; //LCOV_EXCL_LINE if (service->resource_browser != NULL) - g_object_unref(service->resource_browser); + g_object_unref(service->resource_browser); //LCOV_EXCL_LINE g_ssdp_local_services = g_list_remove(g_ssdp_local_services, service); g_free(service->target); @@ -549,7 +554,7 @@ int ssdp_service_set_usn(ssdp_service_h local_service, const char* usn) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, local_service); @@ -593,7 +598,7 @@ int ssdp_service_set_url(ssdp_service_h local_service, const char *url) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, local_service); @@ -635,7 +640,7 @@ int ssdp_service_get_target(ssdp_service_h ssdp_service, char **target) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, ssdp_service); @@ -651,9 +656,9 @@ int ssdp_service_get_target(ssdp_service_h ssdp_service, char **target) *target = g_strndup(service->target, strlen(service->target)); if (!target) { SSDP_LOGE("Failed to get memory for gssdp service type"); - g_free(target); + g_free(target); //LCOV_EXCL_LINE __SSDP_LOG_FUNC_EXIT__; - return SSDP_ERROR_OUT_OF_MEMORY; + return SSDP_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } __SSDP_LOG_FUNC_EXIT__; @@ -676,7 +681,7 @@ int ssdp_service_get_usn(ssdp_service_h ssdp_service, char **usn) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, ssdp_service); @@ -692,9 +697,9 @@ int ssdp_service_get_usn(ssdp_service_h ssdp_service, char **usn) *usn = g_strndup(service->usn, strlen(service->usn)); if (!usn) { SSDP_LOGE("Failed to get memory for gssdp service type"); - g_free(usn); + g_free(usn); //LCOV_EXCL_LINE __SSDP_LOG_FUNC_EXIT__; - return SSDP_ERROR_OUT_OF_MEMORY; + return SSDP_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } __SSDP_LOG_FUNC_EXIT__; @@ -717,7 +722,7 @@ int ssdp_service_get_url(ssdp_service_h ssdp_service, char **url) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, ssdp_service); @@ -733,9 +738,9 @@ int ssdp_service_get_url(ssdp_service_h ssdp_service, char **url) *url = g_strndup(service->url, strlen(service->url)); if (!url) { SSDP_LOGE("Failed to get memory for gssdp service type"); - g_free(url); + g_free(url); //LCOV_EXCL_LINE __SSDP_LOG_FUNC_EXIT__; - return SSDP_ERROR_OUT_OF_MEMORY; + return SSDP_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } __SSDP_LOG_FUNC_EXIT__; @@ -759,7 +764,7 @@ int ssdp_register_local_service(ssdp_service_h local_service, if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, local_service); @@ -831,7 +836,7 @@ int ssdp_deregister_local_service(ssdp_service_h local_service) if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } service = __ssdp_find_local_service(g_ssdp_local_services, local_service); @@ -870,7 +875,7 @@ int ssdp_start_browsing_service(const char* target, ssdp_browser_h* ssdp_browser if (!g_is_gssdp_init) { SSDP_LOGE("gssdp not initialized"); __SSDP_LOG_FUNC_EXIT__; - return SSDP_ERROR_NOT_INITIALIZED; + return SSDP_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE } if (ssdp_browser == NULL) { -- 2.7.4