Commit a8b67611 authored by George Nash's avatar George Nash Committed by Kishen Maloor

Fix type conversion compiler warning

replaced instances of 1.e09 with macro OC_NSEC_PER_SEC set to 1000000000

The value 1.e09 resolves to a double type and causes the following compiler warning

"warning C4244: 'initializing': conversion from 'double' to 'oc_clock_time_t',
 possible loss of data"

Change-Id: Ida8fc8dd71c188a7c2c5695fb9e5dcf4323e8e86
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/29404Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 4a84ea85
......@@ -18,6 +18,8 @@
#include "c-timestamp/timestamp.h"
#include "port/oc_log.h"
#define OC_NSEC_PER_SEC 1000000000
size_t
oc_clock_time_rfc3339(char *out_buf, size_t out_buf_len)
{
......@@ -31,7 +33,7 @@ oc_clock_encode_time_rfc3339(oc_clock_time_t time, char *out_buf,
timestamp_t now_t = { 0 };
now_t.sec = (int64_t)(time / OC_CLOCK_SECOND);
now_t.nsec = (int32_t)((time % OC_CLOCK_SECOND) * (1.e09 / OC_CLOCK_SECOND));
now_t.nsec = (int32_t)((time % OC_CLOCK_SECOND) * (OC_NSEC_PER_SEC / OC_CLOCK_SECOND));
return timestamp_format(out_buf, out_buf_len, &now_t);
}
......@@ -49,7 +51,7 @@ oc_clock_parse_time_rfc3339(const char *in_buf, size_t in_buf_len)
}
oc_clock_time_t t =
((in_time.sec * 1.e09) + in_time.nsec) * OC_CLOCK_SECOND / 1.e09;
((in_time.sec * OC_NSEC_PER_SEC) + in_time.nsec) * OC_CLOCK_SECOND / OC_NSEC_PER_SEC;
return t;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment