Fix for issues reported on SVACE tool for CA
authorkoushik.girijala <g.koushik@samsung.com>
Mon, 29 Feb 2016 13:08:05 +0000 (18:38 +0530)
committerHabib Virji <habib.virji@samsung.com>
Tue, 1 Mar 2016 15:15:37 +0000 (15:15 +0000)
Fixed issues reported on running svace analysis to CA

Change-Id: I761aeccd576744c179da2042917cacf57d6e473b
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5273
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
resource/c_common/ocrandom/src/ocrandom.c
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c

index 525ea9f..95472b6 100644 (file)
 #include <uuid/uuid.h>
 #endif
 
+#if !defined(__ANDROID__) || defined(__linux__) || defined(__APPLE__) || defined(__TIZEN__)
+#define NANO_SEC 1000000000
+#endif
+
 #ifdef ARDUINO
 #include "Arduino.h"
 
@@ -106,15 +110,15 @@ int8_t OCSeedRandom()
 #ifdef __ANDROID__
     struct timespec getTs;
     clock_gettime(CLOCK_MONOTONIC, &getTs);
-    currentTime = (getTs.tv_sec * (uint64_t)1000000000 + getTs.tv_nsec)/1000;
+    currentTime = (getTs.tv_sec * (uint64_t)NANO_SEC + getTs.tv_nsec)/1000;
 #elif  _POSIX_TIMERS > 0
     struct timespec ts;
     clock_gettime(CLOCK_MONOTONIC, &ts);
-    currentTime = ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+    currentTime = (ts.tv_sec * (uint64_t)NANO_SEC + ts.tv_nsec)/ 1000;
 #else
     struct timeval tv;
     gettimeofday(&tv, NULL);
-    currentTime = tv.tv_sec * 1000000 + tv.tv_usec;
+    currentTime = tv.tv_sec * (uint64_t)1000000 + tv.tv_usec;
 #endif
 
     int32_t fd = open("/dev/urandom", O_RDONLY);
index 88427f3..437e535 100644 (file)
@@ -254,7 +254,6 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
     caglobals.ip.nm.numIfItems = 0;
     for (size_t i = 0; i < interfaces; i++)
     {
-        CAResult_t result = CA_STATUS_OK;
         struct ifreq* item = &ifr[i];
         char *name = item->ifr_name;
         struct sockaddr_in *sa4 = (struct sockaddr_in *)&item->ifr_addr;
@@ -286,7 +285,7 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
         }
 
         // Add IPv4 interface
-        result = CAAddInterfaceItem(iflist, ifindex, name, AF_INET, ipv4addr, flags);
+        CAResult_t result = CAAddInterfaceItem(iflist, ifindex, name, AF_INET, ipv4addr, flags);
         if (CA_STATUS_OK != result)
         {
             goto exit;