improve line coverage 25/152025/2 accepted/tizen/unified/20170926.061939 submit/tizen/20170925.023252 submit/tizen/20170925.061816
authorJongkyu Koo <jk.koo@samsung.com>
Fri, 22 Sep 2017 05:22:31 +0000 (14:22 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Mon, 25 Sep 2017 02:15:22 +0000 (02:15 +0000)
Change-Id: Ibaa36ef71d15868911f3ba74b75af0ea6251c6e4
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
client/phnc-dbus.c
client/phnc.c
common/phn-dbus-utils.c
common/phn-property.h
common/phn-record.c
daemon/CMakeLists.txt

index 5c30f304641ec5c8b590480eaac7d3e0fee70496..fd2ae4e1d276f6347bc07b4580b127962465d389 100644 (file)
@@ -31,8 +31,10 @@ int phnc_dbus_connect(void)
        GError *error = NULL;
 
        if (phnc_dbus_object) {
+               /* LCOV_EXCL_START */
                DBG("phnc_dbus_object is already created");
                return PHONE_NUMBER_ERROR_NONE;
+               /* LCOV_EXCL_STOP */
        }
 
 #if !GLIB_CHECK_VERSION(2, 35, 0)
@@ -74,15 +76,20 @@ int phnc_dbus_get_location_from_number(const char *number, phone_number_region_e
        char *out_loc = NULL;
        bool not_connected = phnc_dbus_object ? false : true;
 
-       if (not_connected)
+       if (not_connected) {
+               /* LCOV_EXCL_START */
                phnc_dbus_connect();
+               /* LCOV_EXCL_STOP */
+       }
 
        phn_dbus_call_get_location_sync(phnc_dbus_object, number, region, lang,
                        &out_loc, &ret, NULL, &error);
 
-       if (not_connected)
+       if (not_connected) {
+               /* LCOV_EXCL_START */
                phnc_dbus_disconnect();
-
+               /* LCOV_EXCL_STOP */
+       }
        if (NULL != error) {
                /* LCOV_EXCL_START */
                ERR("phn_dbus_call_get_location_sync() Fail(%s)", error->message);
@@ -303,10 +310,12 @@ int phnc_dbus_get_blocking_rules_related(int user_id, const char *number, phone_
        }
 
        if (PHONE_NUMBER_ERROR_NO_DATA == ret) {
+               /* LCOV_EXCL_START */
                DBG("No blocking rule");
                *rules = NULL;
                *length = 0;
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
        phn_dbus_utils_gvariant_to_array(arg_list, rules, length);
index 3a3deaa86562d4da42d3fd94821403c49541a101..792eade27e1d8403652bdb8fe7a3dc7958f3e45e 100644 (file)
@@ -40,14 +40,20 @@ int phnc_get_uid(void)
 
        ret = sd_pid_get_slice(getpid(), &slice);
        if (0 <= ret && slice) {
-               if (STRING_EQUAL == strncmp(slice, PHNC_SYSTEM_SLICE, strlen(PHNC_SYSTEM_SLICE)))
+               if (STRING_EQUAL == strncmp(slice, PHNC_SYSTEM_SLICE, strlen(PHNC_SYSTEM_SLICE))) {
+                       /* LCOV_EXCL_START */
                        is_in_system = true;
+                       /* LCOV_EXCL_STOP */
+               }
        } else {
+               /* LCOV_EXCL_START */
                ERR("sd_pid_get_slice() Fail(%d)", ret);
+               /* LCOV_EXCL_STOP */
        }
        free(slice);
 
        if (is_in_system) {
+               /* LCOV_EXCL_START */
                int active_user_count = 0;
                uid_t *active_user_list = NULL;
 
@@ -59,6 +65,7 @@ int phnc_get_uid(void)
                                ERR("active_user_count is not 1(%d)", active_user_count);
                        free(active_user_list);
                }
+               /* LCOV_EXCL_STOP */
        }
 
        DBG("uid = %d", uid);
index b975b5927d425c3a0ede5ccd5ae87d96e69967b0..df08081c7e0524cf7deb0c9e461881d86087e3db 100644 (file)
@@ -45,6 +45,7 @@ GVariant* phn_dbus_utils_record_to_gvariant(phone_number_blocking_rule_h record)
        return value;
 }
 
+#ifdef _PHONENUMBER_UTILS_DBUS_SERVER
 GVariant* phn_dbus_utils_list_to_gvariant(GSList *list)
 {
        GVariantBuilder builder;
@@ -69,7 +70,7 @@ GVariant* phn_dbus_utils_list_to_gvariant(GSList *list)
 
        return g_variant_builder_end(&builder);
 }
-
+#endif
 
 int phn_dbus_utils_gvariant_to_record(GVariant *arg_record, phone_number_blocking_rule_h *out_record)
 {
@@ -114,18 +115,22 @@ int phn_dbus_utils_gvariant_to_array(GVariant *arg_list, phone_number_blocking_r
 
                phone_number_blocking_rule_h *array = calloc(cnt, sizeof(phone_number_blocking_rule_h));
                if (NULL == array) {
+                       /* LCOV_EXCL_START */
                        ERR("calloc() fail");
                        return PHONE_NUMBER_ERROR_OUT_OF_MEMORY;
+                       /* LCOV_EXCL_STOP */
                }
 
                int idx = 0;
                while (cursor) {
                        if (idx == cnt) {
+                               /* LCOV_EXCL_START */
                                ERR("g_slist_length() returns wrong value[%d]", cnt);
                                *length = 0;
                                free(array);
                                g_slist_free_full(list, phn_record_free);
                                return PHONE_NUMBER_ERROR_SYSTEM;
+                               /* LCOV_EXCL_STOP */
                        }
 
                        phone_number_blocking_rule_h record = cursor->data;
index 3e185912f6a4c1c4ddac1f0af21ea0615aebc0f9..4d74a994dfd1caa267e8ff907aa768496ef20453 100644 (file)
@@ -38,7 +38,6 @@ typedef enum {
        PHN_PROPERTY_BLOCKING_RULE_MATCH_TYPE        = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_INT) + 1,
        PHN_PROPERTY_BLOCKING_RULE_USER_ID           = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_INT) + 2,
        PHN_PROPERTY_BLOCKING_RULE_NUMBER            = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_STR) + 3,
-       PHN_PROPERTY_BLOCKING_RULE_NORMALIZED_NUMBER = (PHN_PROPERTY_BLOCKING_RULE | PHN_PROPERTY_DATA_TYPE_STR) + 4,
 } phn_property_e;
 
 #endif /* __PHN_PROPERTY_H__ */
index bdccf3807b330a922bc6d5e8b54cec6b118bde8c..c7d7e6c020f3467850bf6a611dc625ec64e8d4f9 100644 (file)
@@ -27,8 +27,10 @@ int phn_record_create(phone_number_blocking_rule_h *out_record)
        phn_blocking_rule_s *p = NULL;
        p = calloc(1, sizeof(phn_blocking_rule_s));
        if (NULL == p) {
+               /* LCOV_EXCL_START */
                ERR("calloc() Fail");
                return PHONE_NUMBER_ERROR_OUT_OF_MEMORY;
+               /* LCOV_EXCL_STOP */
        }
        *out_record = (phone_number_blocking_rule_h)p;
 
@@ -56,12 +58,11 @@ int phn_record_get_str(phone_number_blocking_rule_h record, unsigned int propert
        case PHN_PROPERTY_BLOCKING_RULE_NUMBER:
                *out_value = PHN_STRDUP(p->number);
                break;
-       case PHN_PROPERTY_BLOCKING_RULE_NORMALIZED_NUMBER:
-               *out_value = PHN_STRDUP(p->normalized_number);
-               break;
        default:
+               /* LCOV_EXCL_START */
                ERR("Invalid parameter(perperty:0x%x)", property_id);
                return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
+               /* LCOV_EXCL_STOP */
        }
 
        return PHONE_NUMBER_ERROR_NONE;
@@ -80,12 +81,11 @@ int phn_record_get_int(phone_number_blocking_rule_h record, unsigned int propert
        case PHN_PROPERTY_BLOCKING_RULE_MATCH_TYPE:
                *out_value = (p->match_type);
                break;
-       case PHN_PROPERTY_BLOCKING_RULE_USER_ID:
-               *out_value = (p->user_id);
-               break;
        default:
+               /* LCOV_EXCL_START */
                ERR("Invalid parameter(perperty:0x%x)", property_id);
                return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
+               /* LCOV_EXCL_STOP */
        }
 
        return PHONE_NUMBER_ERROR_NONE;
@@ -102,8 +102,10 @@ int phn_record_set_str(phone_number_blocking_rule_h record, unsigned int propert
                p->number = PHN_STRDUP(value);
                break;
        default:
+               /* LCOV_EXCL_START */
                ERR("Invalid parameter(perperty:0x%x)", property_id);
                return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
+               /* LCOV_EXCL_STOP */
        }
 
        return PHONE_NUMBER_ERROR_NONE;
@@ -117,22 +119,22 @@ int phn_record_set_int(phone_number_blocking_rule_h record, unsigned int propert
        case PHN_PROPERTY_BLOCKING_RULE_MATCH_TYPE:
                p->match_type = value;
                break;
-       case PHN_PROPERTY_BLOCKING_RULE_USER_ID:
-               p->user_id = value;
-               break;
        default:
+               /* LCOV_EXCL_START */
                ERR("Invalid parameter(perperty:0x%x)", property_id);
                return PHONE_NUMBER_ERROR_INVALID_PARAMETER;
+               /* LCOV_EXCL_STOP */
        }
 
        return PHONE_NUMBER_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START */
 void phn_record_free(gpointer data)
 {
        phone_number_blocking_rule_h record = data;
 
        phn_record_destroy(record);
 }
-
+/* LCOV_EXCL_STOP */
 
index 64c7f362ce4545d198a4d3a4d54dc5f01974584d..b84584adf5b1f0359bd2a38142c2203f112c2ef0 100644 (file)
@@ -23,6 +23,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--hash-style=both -pie")
 ADD_DEFINITIONS("-DPHN_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
 ADD_DEFINITIONS("-DPHND_SYS_DB=\"${PHND_SYS_DB}\"")
+ADD_DEFINITIONS("-D_PHONENUMBER_UTILS_DBUS_SERVER")
 
 ADD_EXECUTABLE(${DAEMON} ${DAEMON_SRCS})
 ADD_DEPENDENCIES(${DAEMON} GENERATED_DBUS_CODE)