Eliminate warnings from caadapternetdtls.c
authorJohn Light <john.j.light@intel.com>
Wed, 29 Jul 2015 19:55:38 +0000 (12:55 -0700)
committerErich Keane <erich.keane@intel.com>
Wed, 5 Aug 2015 16:52:35 +0000 (16:52 +0000)
Change-Id: I1ec6bda440ecb435586c872f4c63791c1b80d22a
Signed-off-by: John Light <john.j.light@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2108
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/adapter_util/caadapternetdtls.c

index 92b40c2..90c1ae6 100644 (file)
@@ -207,18 +207,23 @@ static eDtlsRet_t CAAdapterNetDtlsEncryptInternal(const stCADtlsAddrInfo_t *dstS
     int retLen = dtls_write(g_caDtlsContext->dtlsContext, (session_t *)dstSession, data,
                                 dataLen);
     OIC_LOG_V(DEBUG, NET_DTLS_TAG, "dtls_write retun len [%d]", retLen);
+    if (retLen < 0)
+    {
+        OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT FAILURE");
+        return DTLS_FAIL;
+    }
     if (0 == retLen)
     {
         // A new DTLS session was initiated by tinyDTLS library and wait for callback.
         return DTLS_SESSION_INITIATED;
     }
-    else if (dataLen == retLen)
+    else if (dataLen != (uint32_t)retLen)
     {
-        OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
-        return DTLS_OK;
+        OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT FAILURE");
+        return DTLS_FAIL;
     }
-    OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT FAILURE");
-    return DTLS_FAIL;
+    OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
+    return DTLS_OK;
 }
 
 static eDtlsRet_t CAAdapterNetDtlsDecryptInternal(const stCADtlsAddrInfo_t *srcSession,
@@ -364,11 +369,12 @@ static void CASendCachedMsg(const stCADtlsAddrInfo_t *dstSession)
     OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
 }
 
-static int32_t CAReadDecryptedPayload(dtls_context_t *dtlsContext,
+static int32_t CAReadDecryptedPayload(dtls_context_t *context,
                                       session_t *session,
                                       uint8_t *buf,
                                       size_t bufLen )
 {
+    (void)context;
     OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
 
     VERIFY_NON_NULL_RET(session, NET_DTLS_TAG, "Param Session is NULL", 0);
@@ -410,11 +416,12 @@ static int32_t CAReadDecryptedPayload(dtls_context_t *dtlsContext,
     return 0;
 }
 
-static int32_t CASendSecureData(dtls_context_t *dtlsContext,
+static int32_t CASendSecureData(dtls_context_t *context,
                                 session_t *session,
                                 uint8_t *buf,
                                 size_t bufLen)
 {
+    (void)context;
     OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
 
     VERIFY_NON_NULL_RET(session, NET_DTLS_TAG, "Param Session is NULL", -1);
@@ -450,11 +457,12 @@ static int32_t CASendSecureData(dtls_context_t *dtlsContext,
     return bufLen;
 }
 
-static int32_t CAHandleSecureEvent(dtls_context_t *dtlsContext,
+static int32_t CAHandleSecureEvent(dtls_context_t *context,
                                    session_t *session,
                                    dtls_alert_level_t level,
                                    unsigned short code)
 {
+    (void)context;
     OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
 
     VERIFY_NON_NULL_RET(session, NET_DTLS_TAG, "Param Session is NULL", 0);
@@ -528,8 +536,7 @@ static int32_t CAGetPskCredentials(dtls_context_t *ctx,
     {
         // Check if we have the credentials for the device with which we
         // are trying to perform a handshake
-        int index = 0;
-        for (index = 0; index < credInfo->num; index++)
+        for (uint32_t index = 0; index < credInfo->num; index++)
         {
             if (memcmp(desc, credInfo->creds[index].id, DTLS_PSK_ID_LEN) == 0)
             {
@@ -644,7 +651,7 @@ CAResult_t CADtlsEnableAnonECDHCipherSuite(const bool enable)
 
 CAResult_t CADtlsInitiateHandshake(const CAEndpoint_t *endpoint)
 {
-    stCADtlsAddrInfo_t dst = {};
+    stCADtlsAddrInfo_t dst = { 0 };
 
     OIC_LOG(DEBUG, NET_DTLS_TAG, "IN CADtlsInitiateHandshake");
 
@@ -681,7 +688,7 @@ CAResult_t CADtlsInitiateHandshake(const CAEndpoint_t *endpoint)
 
 CAResult_t CADtlsClose(const CAEndpoint_t *endpoint)
 {
-    stCADtlsAddrInfo_t dst = {};
+    stCADtlsAddrInfo_t dst = { 0 };
 
     OIC_LOG(DEBUG, NET_DTLS_TAG, "IN CADtlsDisconnect");
 
@@ -729,7 +736,7 @@ CAResult_t CADtlsGenerateOwnerPSK(const CAEndpoint_t *endpoint,
         return CA_STATUS_INVALID_PARAM;
     }
 
-    stCADtlsAddrInfo_t dst = {};
+    stCADtlsAddrInfo_t dst = { 0 };
 
     CAConvertNameToAddr(endpoint->addr, endpoint->port, &(dst.addr.st));
     dst.ifIndex = 0;
@@ -879,7 +886,7 @@ CAResult_t CAAdapterNetDtlsEncrypt(const CAEndpoint_t *endpoint,
 
     OIC_LOG_V(DEBUG, NET_DTLS_TAG, "Data to be encrypted dataLen [%d]", dataLen);
 
-    stCADtlsAddrInfo_t addrInfo = {};
+    stCADtlsAddrInfo_t addrInfo = { 0 };
 
     CAConvertNameToAddr(endpoint->addr, endpoint->port, &(addrInfo.addr.st));
     addrInfo.ifIndex = 0;
@@ -945,7 +952,7 @@ CAResult_t CAAdapterNetDtlsDecrypt(const CAEndpoint_t *endpoint,
     OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
     VERIFY_NON_NULL_RET(endpoint, NET_DTLS_TAG, "endpoint is NULL" , CA_STATUS_INVALID_PARAM);
 
-    stCADtlsAddrInfo_t addrInfo = {};
+    stCADtlsAddrInfo_t addrInfo = { 0 };
 
     CAConvertNameToAddr(endpoint->addr, endpoint->port, &(addrInfo.addr.st));
     addrInfo.ifIndex = 0;