fixed build warnings in CA common logic
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Wed, 5 Aug 2015 08:44:43 +0000 (17:44 +0900)
committerErich Keane <erich.keane@intel.com>
Thu, 6 Aug 2015 16:32:09 +0000 (16:32 +0000)
modified build warnings in CA common files

Change-Id: If7ba87b32a971d6e8e921f92081051d7959d8380
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2114
Reviewed-by: Naga Ashok Jampani <jn.ashok@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/adapter_util/caadapterutils.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/caretransmission.c

index 2094a6e..56cbe70 100644 (file)
@@ -170,10 +170,9 @@ void CAConvertNameToAddr(const char *host, uint16_t port, struct sockaddr_storag
     VERIFY_NON_NULL_VOID(sockaddr, CA_ADAPTER_UTILS_TAG, "sockaddr is null");
 
     struct addrinfo *addrs;
-    struct addrinfo hints = { 0 };
-    hints.ai_family = AF_UNSPEC;
-    hints.ai_socktype = SOCK_DGRAM;
-    hints.ai_flags = AI_NUMERICHOST;
+    struct addrinfo hints = { .ai_family = AF_UNSPEC,
+                              .ai_socktype = SOCK_DGRAM,
+                              .ai_flags = AI_NUMERICHOST };
 
     int r = getaddrinfo(host, NULL, &hints, &addrs);
     if (r)
index 46ea13c..f5026c1 100644 (file)
@@ -288,7 +288,7 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
     }
 
     // check if block option is set and get block data
-    coap_block_t block = {0};
+    coap_block_t block = {0, 0, 0};
 
     // get block1 option
     int isBlock1 = coap_get_block(pdu, COAP_OPTION_BLOCK1, &block);
@@ -1943,15 +1943,15 @@ CAData_t* CACreateNewDataSet(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint
     VERIFY_NON_NULL_RET(pdu->hdr, TAG, "pdu->hdr", NULL);
     VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint", NULL);
 
-    CAInfo_t responseData = { 0 };
-    responseData.token = (CAToken_t) OICMalloc(pdu->hdr->token_length);
+    CAInfo_t responseData = { .tokenLength = pdu->hdr->token_length };
+    responseData.token = (CAToken_t) OICMalloc(responseData.tokenLength);
     if (NULL == responseData.token)
     {
         OIC_LOG(ERROR, TAG, "out of memory");
         return NULL;
     }
-    memcpy(responseData.token, pdu->hdr->token, pdu->hdr->token_length);
-    responseData.tokenLength = pdu->hdr->token_length;
+    memcpy(responseData.token, pdu->hdr->token, responseData.tokenLength);
+
     CAResponseInfo_t* responseInfo = (CAResponseInfo_t*) OICCalloc(1, sizeof(CAResponseInfo_t));
     if (NULL == responseInfo)
     {
index b19b0db..4f212c2 100644 (file)
@@ -329,15 +329,10 @@ CAResult_t CARetransmissionInitialize(CARetransmission_t *context,
 
     memset(context, 0, sizeof(CARetransmission_t));
 
-    CARetransmissionConfig_t cfg = { 0 };
+    CARetransmissionConfig_t cfg = { .supportType = DEFAULT_RETRANSMISSION_TYPE,
+                                     .tryingCount = DEFAULT_RETRANSMISSION_COUNT };
 
-    if (NULL == config)
-    {
-        // setDefault
-        cfg.supportType = DEFAULT_RETRANSMISSION_TYPE;
-        cfg.tryingCount = DEFAULT_RETRANSMISSION_COUNT;
-    }
-    else
+    if (config)
     {
         cfg = *config;
     }