diff --git a/rcl/test/memory_tools_common.cpp b/rcl/test/memory_tools_common.cpp index a2672ed..c05e4e3 100644 --- a/rcl/test/memory_tools_common.cpp +++ b/rcl/test/memory_tools_common.cpp @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include + #include +#include #if defined(__APPLE__) #include @@ -62,8 +64,10 @@ custom_malloc(size_t size) } } void * memory = malloc(size); + uint64_t fw_size = size; MALLOC_PRINTF( - "malloc expected(%s): %p %llu\n", malloc_expected ? "true " : "false", memory, size); + "malloc expected(%s): %p %" PRIu64 "\n", + malloc_expected ? "true " : "false", memory, fw_size); return memory; } @@ -102,9 +106,10 @@ custom_realloc(void * memory_in, size_t size) } } void * memory = realloc(memory_in, size); + uint64_t fw_size = size; MALLOC_PRINTF( - "realloc expected(%s): %p %p %llu\n", - malloc_expected ? "true " : "false", memory_in, memory, size); + "realloc expected(%s): %p %p %" PRIu64 "\n", + malloc_expected ? "true " : "false", memory_in, memory, fw_size); return memory; } diff --git a/rcl/test/rcl/test_rcl.cpp b/rcl/test/rcl/test_rcl.cpp index b5517a1..3c02c5e 100644 --- a/rcl/test/rcl/test_rcl.cpp +++ b/rcl/test/rcl/test_rcl.cpp @@ -64,27 +64,28 @@ failing_free(void * pointer, void * state) { (void)pointer; (void)state; - return; } struct FakeTestArgv { - FakeTestArgv() : argc(2) + FakeTestArgv() + : argc(2) { - this->argv = (char **)malloc(2 * sizeof(char *)); + this->argv = reinterpret_cast(malloc(2 * sizeof(char *))); if (!this->argv) { throw std::bad_alloc(); } - this->argv[0] = (char *)malloc(10 * sizeof(char)); - sprintf(this->argv[0], "foo"); - this->argv[1] = (char *)malloc(10 * sizeof(char)); - sprintf(this->argv[1], "bar"); + static const size_t size = 10; + this->argv[0] = reinterpret_cast(malloc(size * sizeof(char))); + snprintf(this->argv[0], size, "foo"); + this->argv[1] = reinterpret_cast(malloc(size * sizeof(char))); + snprintf(this->argv[1], size, "bar"); } ~FakeTestArgv() { if (this->argv) { - if (this->argv > 0) { + if (this->argc > 0) { size_t unsigned_argc = this->argc; for (size_t i = 0; i < unsigned_argc; --i) { free(this->argv[i]); @@ -100,8 +101,7 @@ struct FakeTestArgv /* Tests the rcl_init() and rcl_shutdown() functions. */ -TEST_F(TestRCLFixture, test_rcl_init_and_shutdown) -{ +TEST_F(TestRCLFixture, test_rcl_init_and_shutdown) { rcl_ret_t ret; // A shutdown before any init has been called should fail. ret = rcl_shutdown();