use snprintf from rcutils
This commit is contained in:
parent
835a90761c
commit
abf331e81f
2 changed files with 5 additions and 9 deletions
|
@ -29,6 +29,7 @@ extern "C"
|
||||||
#include "rcutils/get_env.h"
|
#include "rcutils/get_env.h"
|
||||||
#include "rcutils/logging_macros.h"
|
#include "rcutils/logging_macros.h"
|
||||||
#include "rcutils/macros.h"
|
#include "rcutils/macros.h"
|
||||||
|
#include "rcutils/snprintf.h"
|
||||||
#include "rmw/error_handling.h"
|
#include "rmw/error_handling.h"
|
||||||
#include "rmw/node_security_options.h"
|
#include "rmw/node_security_options.h"
|
||||||
#include "rmw/rmw.h"
|
#include "rmw/rmw.h"
|
||||||
|
@ -37,12 +38,6 @@ extern "C"
|
||||||
|
|
||||||
#include "./common.h"
|
#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_ROOT_DIRECTORY_VAR_NAME "ROS_SECURITY_ROOT_DIRECTORY"
|
||||||
#define ROS_SECURITY_STRATEGY_VAR_NAME "ROS_SECURITY_STRATEGY"
|
#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);
|
const char * msg = rmw_namespace_validation_result_string(validation_result);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
char fixed_msg[256];
|
char fixed_msg[256];
|
||||||
LOCAL_SNPRINTF(
|
rcutils_snprintf(
|
||||||
fixed_msg, sizeof(fixed_msg),
|
fixed_msg, sizeof(fixed_msg),
|
||||||
"unknown validation_result '%d', this should not happen", validation_result);
|
"unknown validation_result '%d', this should not happen", validation_result);
|
||||||
RCL_SET_ERROR_MSG(fixed_msg, *allocator);
|
RCL_SET_ERROR_MSG(fixed_msg, *allocator);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "../memory_tools/memory_tools.hpp"
|
#include "../memory_tools/memory_tools.hpp"
|
||||||
#include "rcl/error_handling.h"
|
#include "rcl/error_handling.h"
|
||||||
|
#include "rcutils/snprintf.h"
|
||||||
|
|
||||||
#ifdef RMW_IMPLEMENTATION
|
#ifdef RMW_IMPLEMENTATION
|
||||||
# define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX
|
# define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX
|
||||||
|
@ -60,9 +61,9 @@ struct FakeTestArgv
|
||||||
}
|
}
|
||||||
static const size_t size = 10;
|
static const size_t size = 10;
|
||||||
this->argv[0] = reinterpret_cast<char *>(malloc(size * sizeof(char)));
|
this->argv[0] = reinterpret_cast<char *>(malloc(size * sizeof(char)));
|
||||||
snprintf(this->argv[0], size, "foo");
|
rcutils_snprintf(this->argv[0], size, "foo");
|
||||||
this->argv[1] = reinterpret_cast<char *>(malloc(size * sizeof(char)));
|
this->argv[1] = reinterpret_cast<char *>(malloc(size * sizeof(char)));
|
||||||
snprintf(this->argv[1], size, "bar");
|
rcutils_snprintf(this->argv[1], size, "bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
~FakeTestArgv()
|
~FakeTestArgv()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue