Fix build warning 85/278685/1 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/7.0/unified/hotfix/20221116.104904 accepted/tizen/unified/20220803.131515 submit/tizen/20220803.020401 tizen_7.0_m2_release
authorcheoleun moon <chleun.moon@samsung.com>
Mon, 25 Jul 2022 05:53:13 +0000 (14:53 +0900)
committercheoleun moon <chleun.moon@samsung.com>
Mon, 25 Jul 2022 05:53:19 +0000 (14:53 +0900)
Change-Id: I3ce6df163b8cb66c4c1d0b8a11ead33c5a00e435

plugins/ble-gatt/ble-gatt-plugin.cpp
plugins/dns-sd/dns-sd-plugin.cpp
plugins/nan/nan-plugin.cpp
src/vine-dp.cpp
src/vine-service.cpp
tests/vine-test/vine-ble-test.cpp

index 373f65d..cb02df9 100755 (executable)
@@ -261,7 +261,7 @@ static void __gatt_server_write_connection_value_requested_cb(const char *remote
        vine_gatt_s *gatt = (vine_gatt_s *)user_data;
 
        if (bt_gatt_server_send_response(request_id, BT_GATT_REQUEST_TYPE_WRITE,
-                               offset, BT_ERROR_NONE, "", 0) != BT_ERROR_NONE) {
+                               offset, BT_ERROR_NONE, (char *)"", 0) != BT_ERROR_NONE) {
                VINE_LOGE("Failed to send initiation message");
                return;
        }
index 6f6bdc0..7f69ea2 100755 (executable)
@@ -75,7 +75,9 @@ static dns_sd_discovered_service_s *__create_discovered_service(
 {
        dns_sd_discovered_service_s *service = new dns_sd_discovered_service_s;
        strncpy(service->service_type, service_type, VINE_MAX_SERVICE_TYPE_LEN);
+       service->service_type[VINE_MAX_SERVICE_TYPE_LEN] = '\0';
        strncpy(service->service_name, service_name, VINE_MAX_SERVICE_NAME_LEN);
+       service->service_name[VINE_MAX_SERVICE_NAME_LEN] = '\0';
        service->dns_sd_handle = dns_sd_handle;
        return service;
 }
@@ -582,6 +584,7 @@ vine_disc_error dns_sd_subscribe(void *plugin_handle,
        const char *domain = NULL;
 
        strncpy(dns_sd_handle->service_type, service_type, VINE_MAX_SERVICE_TYPE_LEN);
+       dns_sd_handle->service_type[VINE_MAX_SERVICE_TYPE_LEN] = '\0';
        char stype[VINE_DNS_SD_SERVICE_TYPE_MAX_LEN + 1];
        snprintf(stype, VINE_DNS_SD_SERVICE_TYPE_MAX_LEN,
                VINE_DNS_SD_SERVICE_TYPE ",%s", service_type);
index 8438d4e..8a1581f 100755 (executable)
@@ -45,7 +45,6 @@ typedef struct {
        int port;
 } vine_nan_s;
 
-static bool __is_nan_enabled = false;
 static vine_disc_plugin_callbacks event_callbacks;
 
 static vine_disc_error __convert_nan_error_to_vine_disc_error(int error)
index 2a16363..dbbc195 100755 (executable)
@@ -1239,7 +1239,7 @@ int DPPubSub::publish_service()
        // The length of value is at most (VINE_MAX_ATTRIBUTE_LEN(252) - key length(2) - 1 = 249)
        // Therefore, at most five attributes can be added for a topic.
        VINE_LOGD("Topic[%s] is added as attributes", mTopic.c_str());
-       while (pos < mTopic.size()) {
+       while (pos < (int)mTopic.size()) {
                std::string val = mTopic.substr(pos, VINE_MAX_ATTRIBUTE_LEN - 1 - 2);
                char key[3];
                key[0] = 'T';
index d5b8258..52b8459 100755 (executable)
@@ -116,15 +116,15 @@ int _vine_service_clone(vine_service_h origin, vine_service_h *cloned)
        vine_service_s *cloned_service = new vine_service_s;
 
        cloned_service->type = origin_service->type;
-       strncpy(cloned_service->service_type, origin_service->service_type, VINE_MAX_SERVICE_TYPE_LEN);
-       strncpy(cloned_service->service_name, origin_service->service_name, VINE_MAX_SERVICE_NAME_LEN);
-       strncpy(cloned_service->host_name, origin_service->host_name, VINE_MAX_HOST_NAME_LEN);
-       strncpy(cloned_service->ip, origin_service->ip, VINE_MAX_IP_LEN);
+       memcpy(cloned_service->service_type, origin_service->service_type, VINE_MAX_SERVICE_TYPE_LEN + 1);
+       memcpy(cloned_service->service_name, origin_service->service_name, VINE_MAX_SERVICE_NAME_LEN + 1);
+       memcpy(cloned_service->host_name, origin_service->host_name, VINE_MAX_HOST_NAME_LEN + 1);
+       memcpy(cloned_service->ip, origin_service->ip, VINE_MAX_IP_LEN + 1);
        cloned_service->family = origin_service->family;
        cloned_service->port = origin_service->port;
        cloned_service->attributes = origin_service->attributes;
-       strncpy(cloned_service->iface_name, origin_service->iface_name, IF_NAMESIZE);
-       strncpy(cloned_service->mac, origin_service->mac, VINE_MAC_LEN);
+       memcpy(cloned_service->iface_name, origin_service->iface_name, IF_NAMESIZE + 1);
+       memcpy(cloned_service->mac, origin_service->mac, VINE_MAC_LEN + 1);
        cloned_service->state = origin_service->state;
 
        cloned_service->disc_handle = NULL;
@@ -148,6 +148,7 @@ int _vine_service_set_type(
 
        vine_service_s *s = (vine_service_s *)service;
        strncpy(s->service_type, service_type, VINE_MAX_SERVICE_TYPE_LEN);
+       s->service_type[VINE_MAX_SERVICE_TYPE_LEN] = '\0';
 
        return VINE_ERROR_NONE;
 }
@@ -169,6 +170,7 @@ int _vine_service_set_name(
 
        vine_service_s *s = (vine_service_s *)service;
        strncpy(s->service_name, service_name, VINE_MAX_SERVICE_TYPE_LEN);
+       s->service_name[VINE_MAX_SERVICE_NAME_LEN] = '\0';
 
        return VINE_ERROR_NONE;
 }
index 711bcac..f45325c 100755 (executable)
@@ -52,26 +52,6 @@ static vine_dp_h g_client_dp = NULL;
 static std::list<vine_dp_h> g_datapath_list;
 static std::list<vine_service_h> g_service_list;
 
-static bool test_get_user_string(const char *msg, char *buf, int buf_size)
-{
-       if (msg == NULL || buf == NULL || buf_size < 2)
-               return false;
-
-       int ret;
-       printf("%s", msg);
-       fflush(stdout);
-       memset(buf, 0, buf_size);
-       ret = read(0, buf, buf_size - 1);
-
-       if (ret < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
-               buf[0] = '\0';
-               return false;
-       }
-
-       buf[ret - 1] = '\0';
-       return true;
-}
-
 static void __quit()
 {
        PRINT_IF_ERROR(vine_deinitialize(), "vine_initialize()");