Merge pull request #75 from ros2/fix_time_arm32

Avoid overflow on 32-bit machines when working with large ns values
This commit is contained in:
gerkey 2016-08-24 17:05:24 -07:00 committed by GitHub
commit 0abda63db3

View file

@ -66,7 +66,7 @@ rcl_system_time_now(rcl_time_point_value_t * now)
RCL_SET_ERROR_MSG("unexpected negative time");
return RCL_RET_ERROR;
}
*now = RCL_S_TO_NS(timespec_now.tv_sec) + timespec_now.tv_nsec;
*now = RCL_S_TO_NS((uint64_t)timespec_now.tv_sec) + timespec_now.tv_nsec;
return RCL_RET_OK;
}
@ -97,7 +97,7 @@ rcl_steady_time_now(rcl_time_point_value_t * now)
RCL_SET_ERROR_MSG("unexpected negative time");
return RCL_RET_ERROR;
}
*now = RCL_S_TO_NS(timespec_now.tv_sec) + timespec_now.tv_nsec;
*now = RCL_S_TO_NS((uint64_t)timespec_now.tv_sec) + timespec_now.tv_nsec;
return RCL_RET_OK;
}