Remove useless local variables 15/202115/2 accepted/tizen/unified/20190325.070948 submit/tizen/20190325.013255
authorCheoleun Moon <chleun.moon@samsung.com>
Mon, 25 Mar 2019 01:18:39 +0000 (10:18 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Mon, 25 Mar 2019 01:31:12 +0000 (10:31 +0900)
Change-Id: I52e6dffea4a4ddbbf18c6fc9bec8884a0dd3f22f
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
packaging/capi-network-nsd.spec
src/dns-sd/dns-sd.c

index 605a7866e6590999ef4ead304e382693e1402b71..3a821dcc202109c1acf36a503195d0b6d0b9fdea 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-network-nsd
 Summary:    A Network Service Discovery libraries in Native API
-Version:    0.0.24
+Version:    0.0.25
 Release:    1
 Group:      System/Network
 License:    Apache-2.0
index f9d8f26228990613f8a308eb1132037790782712..c5c18b59c1f90cbb4513d3d544e55e5a162eb0ba 100644 (file)
@@ -742,8 +742,6 @@ int dnssd_service_set_record(dnssd_service_h local_service, unsigned short type,
        int ret;
        dnssd_handle_s *local_handle = NULL;
        dnssd_register_data_s *reg;
-       DNSServiceRef sd_ref;
-       DNSRecordRef record_client;
 
        CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE);
 
@@ -767,17 +765,15 @@ int dnssd_service_set_record(dnssd_service_h local_service, unsigned short type,
        }
 
        reg = GET_REG_DATA_P(local_handle);
-       sd_ref = local_handle->sd_ref;
-       record_client = reg->record_ref;
        DNSSD_LOGD("Record Type %d Record len %d", type, length);
 
-       if (record_client == NULL) {
+       if (reg->record_ref == NULL) {
                DNSSD_LOGD("Adding DNS Service Record");
-               ret = DNSServiceAddRecord(sd_ref, &(reg->record_ref),
+               ret = DNSServiceAddRecord(local_handle->sd_ref, &(reg->record_ref),
                                local_handle->flags, type, length, data, 0);
        } else {
                DNSSD_LOGD("Updating DNS Service Record");                      //LCOV_EXCL_LINE
-               ret = DNSServiceUpdateRecord(sd_ref, record_client,     //LCOV_EXCL_LINE
+               ret = DNSServiceUpdateRecord(local_handle->sd_ref, reg->record_ref,     //LCOV_EXCL_LINE
                                local_handle->flags, length, data, 0);          //LCOV_EXCL_LINE
        }
 
@@ -801,8 +797,6 @@ int dnssd_service_unset_record(dnssd_service_h local_service,
        int ret;
        dnssd_handle_s *local_handle;
        dnssd_register_data_s *reg;
-       DNSServiceRef sd_ref;
-       DNSRecordRef record_client;
        int dnssd_err = 0;
        uint32_t version = 0;
        uint32_t size = sizeof(version);
@@ -829,10 +823,8 @@ int dnssd_service_unset_record(dnssd_service_h local_service,
        }
 
        reg = GET_REG_DATA_P(local_handle);
-       sd_ref = local_handle->sd_ref;
-       record_client = reg->record_ref;
 
-       if (NULL == record_client) {
+       if (reg->record_ref == NULL) {
                DNSSD_LOGE("Invalid DNS SD Client");
                __DNSSD_LOG_FUNC_EXIT__;
                return DNSSD_ERROR_INVALID_PARAMETER;
@@ -844,7 +836,7 @@ int dnssd_service_unset_record(dnssd_service_h local_service,
        else
                DNSSD_LOGE("Daemon is not running");
 
-       ret = DNSServiceRemoveRecord(sd_ref, record_client,
+       ret = DNSServiceRemoveRecord(local_handle->sd_ref, reg->record_ref,
                        local_handle->flags);
        if (ret < 0) {
                DNSSD_LOGE("Failed to Remove Record for DNS Service, error[%s]",        //LCOV_EXCL_LINE
@@ -910,7 +902,6 @@ int dnssd_register_local_service(dnssd_service_h local_service,
        int ret;
        dnssd_handle_s *local_handle = NULL;
        dnssd_register_data_s *reg = NULL;
-       DNSServiceRef *sd_ref;
        void *data;
        unsigned short length;
 
@@ -947,7 +938,6 @@ int dnssd_register_local_service(dnssd_service_h local_service,
        }
 
        reg = GET_REG_DATA_P(local_handle);
-       sd_ref = &(local_handle->sd_ref);
 
        if (reg->service_name == NULL) {
                DNSSD_LOGD("No Service Name Provided"); //LCOV_EXCL_LINE
@@ -960,7 +950,7 @@ int dnssd_register_local_service(dnssd_service_h local_service,
 
        dnssd_service_get_all_txt_record(local_service, &length, &data);
 
-       ret = DNSServiceRegister(sd_ref, local_handle->flags,
+       ret = DNSServiceRegister(&(local_handle->sd_ref), local_handle->flags,
                        reg->if_index, reg->service_name,
                        local_handle->service_type, local_handle->domain,
                        NULL, htons((unsigned short int)reg->port),
@@ -988,8 +978,6 @@ int dnssd_deregister_local_service(dnssd_service_h local_service)
        __DNSSD_LOG_FUNC_ENTER__;
        dnssd_handle_s *local_handle = NULL;
        dnssd_register_data_s *reg;
-       DNSServiceRef sd_ref;
-       DNSRecordRef record_client;
        int ret;
 
        CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE);
@@ -1013,17 +1001,15 @@ int dnssd_deregister_local_service(dnssd_service_h local_service)
                return DNSSD_ERROR_SERVICE_NOT_FOUND;
        }
 
-       sd_ref = local_handle->sd_ref;
-       if (NULL == sd_ref) {
+       if (local_handle->sd_ref == NULL) {
                DNSSD_LOGE("Invalid DNS SD Client");
                __DNSSD_LOG_FUNC_EXIT__;
                return DNSSD_ERROR_INVALID_PARAMETER;
        }
 
        reg = GET_REG_DATA_P(local_handle);
-       record_client = reg->record_ref;
-       if (record_client) {
-               ret = DNSServiceRemoveRecord(sd_ref, record_client,
+       if (reg->record_ref) {
+               ret = DNSServiceRemoveRecord(local_handle->sd_ref, reg->record_ref,
                                local_handle->flags);
                if (ret < 0)    //LCOV_EXCL_LINE
                        DNSSD_LOGE("Failed to Remove Record for DNS Service, "  //LCOV_EXCL_LINE
@@ -1037,7 +1023,7 @@ int dnssd_deregister_local_service(dnssd_service_h local_service)
                local_handle->watch_id = 0;
        }
 
-       DNSServiceRefDeallocate(sd_ref);
+       DNSServiceRefDeallocate(local_handle->sd_ref);
        local_handle->sd_ref = NULL;
 
        __DNSSD_LOG_FUNC_EXIT__;
@@ -1145,7 +1131,6 @@ static int __dnssd_getaddrinfo(dnssd_handle_s *dnssd_handle, unsigned int flags,
                unsigned short txt_len, int port)
 {
        int ret;
-       DNSServiceRef *sd_ref;
        dnssd_handle_s *local_handle = NULL;
        dnssd_found_data_s *found = NULL;
        char *name;
@@ -1207,9 +1192,7 @@ static int __dnssd_getaddrinfo(dnssd_handle_s *dnssd_handle, unsigned int flags,
 
        DNSSD_LOGD("g_slist length [%d]", g_slist_length(dnssd_handle_list));
 
-       sd_ref = &(local_handle->sd_ref);
-
-       ret = DNSServiceGetAddrInfo(sd_ref, flags, if_index,
+       ret = DNSServiceGetAddrInfo(&(local_handle->sd_ref), flags, if_index,
                        dns_protocol, host_name,
                        __dnssd_getaddrinfo_reply_cb, local_handle);
        if (ret < 0) {
@@ -1272,7 +1255,6 @@ static int __dnssd_resolve_dns_service(dnssd_handle_s *dnssd_handle,
        __DNSSD_LOG_FUNC_ENTER__;
        int ret;
        resolve_reply_data *data;
-       DNSServiceRef *sd_ref;
 
        data = g_try_malloc0(sizeof(resolve_reply_data));
        if (data == NULL) {
@@ -1287,9 +1269,7 @@ static int __dnssd_resolve_dns_service(dnssd_handle_s *dnssd_handle,
 
        resolve_handle_list = g_slist_prepend(resolve_handle_list, data);
 
-       sd_ref = &(data->sd_ref);
-
-       ret = DNSServiceResolve(sd_ref, flags, if_index, service_name,
+       ret = DNSServiceResolve(&(data->sd_ref), flags, if_index, service_name,
                        type, domain, __dnssd_resolve_reply_cb, data);
        if (ret < 0) {
                DNSSD_LOGE("Failed to Resolve DNS Service, error[%s]",
@@ -1418,7 +1398,6 @@ int dnssd_start_browsing_service(const char *service_type,
        int ret;
        dnssd_handle_s *local_handle;
        dnssd_browse_data_s *browse;
-       DNSServiceRef *sd_ref;
        unsigned int handler;
 
        CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE);
@@ -1463,12 +1442,11 @@ int dnssd_start_browsing_service(const char *service_type,
        local_handle->flags = 0;
        local_handle->watch_id = 0;
        browse = GET_BROWSE_DATA_P(local_handle);
-       sd_ref = &(local_handle->sd_ref);
 
        DNSSD_LOGD("New browse handle created [%p]->[%u] type %s", local_handle,
                        *dnssd_service, local_handle->service_type);
 
-       ret = DNSServiceBrowse(sd_ref, local_handle->flags,
+       ret = DNSServiceBrowse(&(local_handle->sd_ref), local_handle->flags,
                        kDNSServiceInterfaceIndexAny, local_handle->service_type,
                        local_handle->domain, __dnssd_browse_reply_cb,
                        NULL);
@@ -1500,7 +1478,6 @@ int dnssd_start_browsing_service_on_interface(const char *service_type, const ch
        int ret;
        dnssd_handle_s *local_handle;
        dnssd_browse_data_s *browse;
-       DNSServiceRef *sd_ref;
        unsigned int handler;
        unsigned int if_index;
 
@@ -1549,12 +1526,11 @@ int dnssd_start_browsing_service_on_interface(const char *service_type, const ch
        local_handle->flags = 0;
        local_handle->watch_id = 0;
        browse = GET_BROWSE_DATA_P(local_handle);
-       sd_ref = &(local_handle->sd_ref);
 
        DNSSD_LOGD("New browse handle created [%p]->[%u] type %s", local_handle,
                        *dnssd_service, local_handle->service_type);
 
-       ret = DNSServiceBrowse(sd_ref, local_handle->flags,
+       ret = DNSServiceBrowse(&(local_handle->sd_ref), local_handle->flags,
                        if_index, local_handle->service_type,
                        local_handle->domain, __dnssd_browse_reply_cb,
                        NULL);
@@ -1618,7 +1594,6 @@ int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service)
 {
        __DNSSD_LOG_FUNC_ENTER__;
        dnssd_handle_s *local_handle;
-       DNSServiceRef sd_ref;
        GSList *list;
        resolve_reply_data *resolve_data;
 
@@ -1643,8 +1618,7 @@ int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service)
                return DNSSD_ERROR_INVALID_PARAMETER;
        }
 
-       sd_ref = local_handle->sd_ref;
-       if (NULL == sd_ref) {
+       if (local_handle->sd_ref == NULL) {
                DNSSD_LOGE("Invalid DNS SD Client");    //LCOV_EXCL_LINE
                __DNSSD_LOG_FUNC_EXIT__;        //LCOV_EXCL_LINE
                return DNSSD_ERROR_INVALID_PARAMETER;   //LCOV_EXCL_LINE
@@ -1674,8 +1648,8 @@ int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service)
        if (local_handle->watch_id > 0)
                g_source_remove(local_handle->watch_id);
 
-       DNSServiceRefDeallocate(sd_ref);
-       sd_ref = NULL;
+       DNSServiceRefDeallocate(local_handle->sd_ref);
+       local_handle->sd_ref = NULL;
 
        DNSSD_LOGD("g_slist length [%d]", g_slist_length(dnssd_handle_list));
        __DNSSD_LOG_FUNC_EXIT__;