From abf331e81f032dc21583ae2a4a6bf20650311c28 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Thu, 10 Aug 2017 12:08:44 -0700 Subject: [PATCH] use snprintf from rcutils --- rcl/src/rcl/node.c | 9 ++------- rcl/test/rcl/test_rcl.cpp | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index dbac782..7088cf9 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -29,6 +29,7 @@ extern "C" #include "rcutils/get_env.h" #include "rcutils/logging_macros.h" #include "rcutils/macros.h" +#include "rcutils/snprintf.h" #include "rmw/error_handling.h" #include "rmw/node_security_options.h" #include "rmw/rmw.h" @@ -37,12 +38,6 @@ extern "C" #include "./common.h" -#ifndef _WIN32 - #define LOCAL_SNPRINTF snprintf -#else - #define LOCAL_SNPRINTF(buffer, buffer_size, format, ...) \ - _snprintf_s(buffer, buffer_size, _TRUNCATE, format, __VA_ARGS__) -#endif #define ROS_SECURITY_ROOT_DIRECTORY_VAR_NAME "ROS_SECURITY_ROOT_DIRECTORY" #define ROS_SECURITY_STRATEGY_VAR_NAME "ROS_SECURITY_STRATEGY" @@ -174,7 +169,7 @@ rcl_node_init( const char * msg = rmw_namespace_validation_result_string(validation_result); if (!msg) { char fixed_msg[256]; - LOCAL_SNPRINTF( + rcutils_snprintf( fixed_msg, sizeof(fixed_msg), "unknown validation_result '%d', this should not happen", validation_result); RCL_SET_ERROR_MSG(fixed_msg, *allocator); diff --git a/rcl/test/rcl/test_rcl.cpp b/rcl/test/rcl/test_rcl.cpp index 92cd816..83194a9 100644 --- a/rcl/test/rcl/test_rcl.cpp +++ b/rcl/test/rcl/test_rcl.cpp @@ -18,6 +18,7 @@ #include "../memory_tools/memory_tools.hpp" #include "rcl/error_handling.h" +#include "rcutils/snprintf.h" #ifdef RMW_IMPLEMENTATION # define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX @@ -60,9 +61,9 @@ struct FakeTestArgv } static const size_t size = 10; this->argv[0] = reinterpret_cast(malloc(size * sizeof(char))); - snprintf(this->argv[0], size, "foo"); + rcutils_snprintf(this->argv[0], size, "foo"); this->argv[1] = reinterpret_cast(malloc(size * sizeof(char))); - snprintf(this->argv[1], size, "bar"); + rcutils_snprintf(this->argv[1], size, "bar"); } ~FakeTestArgv()