[IOT-2737] Fix build warning in routing layer.
authorSenthil Kumar G S <senthil.gs@samsung.com>
Fri, 18 Aug 2017 13:07:11 +0000 (18:37 +0530)
committerSenthil Kumar G S <senthil.gs@samsung.com>
Wed, 20 Sep 2017 05:19:16 +0000 (05:19 +0000)
Warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing].

Change-Id: I19a851e0bf16e4b46ba6b7ed1167cb50c4502f18
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Origin: https://gerrit.iotivity.org/gerrit/#/c/22003/

resource/csdk/routing/src/routingutility.c

index 8df03d6..1dca935 100644 (file)
@@ -253,8 +253,10 @@ OCStackResult RMUpdateInfo(CAHeaderOption_t **options, uint8_t *numOptions,
         {
             memcpy(endpoint->routeData, (*options + routeIndex)->optionData + count,
                    GATEWAY_ID_LENGTH);
-            OIC_LOG_V(DEBUG, TAG, "adding srcgid: %u in endpoint [%d]",
-                     *((uint32_t *)endpoint->routeData), sLen);
+
+            uint32_t rData1 = 0;
+            memcpy(&rData1, endpoint->routeData, sizeof(rData1));
+            OIC_LOG_V(DEBUG, TAG, "adding srcgid: %u in endpoint [%d]", rData1, sLen);
 
             count += GATEWAY_ID_LENGTH;
 
@@ -262,8 +264,10 @@ OCStackResult RMUpdateInfo(CAHeaderOption_t **options, uint8_t *numOptions,
             {
                 memcpy(endpoint->routeData + GATEWAY_ID_LENGTH,
                        (*options + routeIndex)->optionData + count, ENDPOINT_ID_LENGTH);
-                OIC_LOG_V(DEBUG, TAG, "adding srceid: %u in endpoint",
-                         *((uint16_t *)(endpoint->routeData + GATEWAY_ID_LENGTH)));
+
+                uint16_t rData2 = 0;
+                memcpy(&rData2, endpoint->routeData + GATEWAY_ID_LENGTH, sizeof(rData2));
+                OIC_LOG_V(DEBUG, TAG, "adding srceid: %u in endpoint", rData2);
             }
         }
     }