Removing unneccesary floating point conversions.
authorMandeep Shetty <mandeep.shetty@intel.com>
Thu, 5 Mar 2015 22:35:29 +0000 (14:35 -0800)
committerSashi Penta <sashi.kumar.penta@intel.com>
Fri, 6 Mar 2015 01:37:11 +0000 (01:37 +0000)
Remove casting uint types to float in presence bounds calculation
and using division with a single floating point constant instead.

Change-Id: I7b1738753ccec3109c698774204d3d92fde7de21
Signed-off-by: Mandeep Shetty <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/443
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
resource/csdk/stack/src/ocstack.c

index fdb4d42..fd7fd82 100644 (file)
@@ -552,10 +552,8 @@ OCStackResult HandlePresenceResponse(const CARemoteEndpoint_t* endPoint,
             cbNode->presence->TTL = maxAge;
             for(int index = 0; index < PresenceTimeOutSize; index++)
             {
-                lowerBound = GetTime(((float)(PresenceTimeOut[index])
-                        /(float)100)*(float)cbNode->presence->TTL);
-                higherBound = GetTime(((float)(PresenceTimeOut[index + 1])
-                        /(float)100)*(float)cbNode->presence->TTL);
+                lowerBound = GetTime(PresenceTimeOut[index]/ 100.0f*cbNode->presence->TTL);
+                higherBound = GetTime(PresenceTimeOut[index + 1]/100.0f*cbNode->presence->TTL);
                 cbNode->presence->timeOut[index] = OCGetRandomRange(lowerBound, higherBound);
                 OC_LOG_V(DEBUG, TAG, "----------------lowerBound timeout  %d", lowerBound);
                 OC_LOG_V(DEBUG, TAG, "----------------higherBound timeout %d", higherBound);