Skip to content

Commit

Permalink
Converted reinterpret_cast to static_cast where I felt it was safe-ish
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Hassold <[email protected]>
  • Loading branch information
Jacob Hassold committed Apr 16, 2019
1 parent 26744b0 commit 0144782
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion rcl/test/rcl/test_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct FakeTestArgv
: allocator(rcutils_get_default_allocator()), argc(2)
{
this->argv =
reinterpret_cast<char **>(allocator.allocate(2 * sizeof(char *), allocator.state));
static_cast<char **>(allocator.allocate(2 * sizeof(char *), allocator.state));
if (!this->argv) {
throw std::bad_alloc();
}
Expand Down
36 changes: 18 additions & 18 deletions rcl/test/rcl/test_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), default_clock_instanciation) {
});
ASSERT_TRUE(rcl_clock_valid(&ros_clock));

rcl_clock_t * steady_clock = reinterpret_cast<rcl_clock_t *>(
auto * steady_clock = static_cast<rcl_clock_t *>(
allocator.zero_allocate(1, sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(steady_clock, allocator.state);
Expand All @@ -235,7 +235,7 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), default_clock_instanciation) {
});
ASSERT_TRUE(rcl_clock_valid(steady_clock));

rcl_clock_t * system_clock = reinterpret_cast<rcl_clock_t *>(
auto * system_clock = static_cast<rcl_clock_t *>(
allocator.zero_allocate(1, sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(system_clock, allocator.state);
Expand Down Expand Up @@ -289,8 +289,8 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), specific_clock_instantiation) {

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_difference) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * ros_clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto ros_clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(ros_clock, allocator.state);
});
Expand Down Expand Up @@ -324,8 +324,8 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_difference) {

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_difference_signed) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * ros_clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto * ros_clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(ros_clock, allocator.state);
});
Expand Down Expand Up @@ -405,8 +405,8 @@ void reset_callback_triggers(void)

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_clock_change_callbacks) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * ros_clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto * ros_clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(ros_clock, allocator.state);
});
Expand Down Expand Up @@ -468,8 +468,8 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_clock_change_callbacks) {

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_forward_jump_callbacks) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * ros_clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto * ros_clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(ros_clock, allocator.state);
});
Expand Down Expand Up @@ -529,8 +529,8 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_forward_jump_callbacks) {

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_backward_jump_callbacks) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * ros_clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto * ros_clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(ros_clock, allocator.state);
});
Expand Down Expand Up @@ -589,8 +589,8 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_time_backward_jump_callbacks)

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_clock_add_jump_callback) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto * clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(clock, allocator.state);
});
Expand Down Expand Up @@ -625,8 +625,8 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_clock_add_jump_callback) {

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_clock_remove_jump_callback) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto * clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(clock, allocator.state);
});
Expand Down Expand Up @@ -673,8 +673,8 @@ TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), rcl_clock_remove_jump_callback) {

TEST(CLASSNAME(rcl_time, RMW_IMPLEMENTATION), add_remove_add_jump_callback) {
rcl_allocator_t allocator = rcl_get_default_allocator();
rcl_clock_t * clock =
reinterpret_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
auto * clock =
static_cast<rcl_clock_t *>(allocator.allocate(sizeof(rcl_clock_t), allocator.state));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
allocator.deallocate(clock, allocator.state);
});
Expand Down

0 comments on commit 0144782

Please sign in to comment.