Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suppress false positive from clang-tidy #951

Merged
merged 2 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions rcl/include/rcl/logging_rosout.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ rcl_logging_rosout_fini_publisher_for_node(
* message out via that publisher. If there is no publisher directly correlated
* with the logger then nothing will be done.
*
* This function is meant to be registered with the logging functions for rcutils
* This function is meant to be registered with the logging functions for
* rcutils, and shouldn't be used outside of that context.
* Additionally, arguments like args should be non-null and properly initialized
* otherwise it is undefined behavior.
*
* <hr>
* Attribute | Adherence
Expand All @@ -176,7 +179,8 @@ rcl_logging_rosout_fini_publisher_for_node(
* \param[in] args argument for the string format
*/
RCL_PUBLIC
void rcl_logging_rosout_output_handler(
void
rcl_logging_rosout_output_handler(
const rcutils_log_location_t * location,
int severity,
const char * name,
Expand Down
11 changes: 8 additions & 3 deletions rcl/src/rcl/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ static
void
rcl_logging_ext_lib_output_handler(
const rcutils_log_location_t * location,
int severity, const char * name, rcutils_time_point_value_t timestamp,
const char * format, va_list * args)
int severity,
const char * name,
rcutils_time_point_value_t timestamp,
const char * format,
va_list * args)
{
rcl_ret_t status;
char msg_buf[1024] = "";
Expand All @@ -188,7 +191,9 @@ rcl_logging_ext_lib_output_handler(
};

va_list args_clone;
va_copy(args_clone, *args);
// The args are initialized, but clang-tidy cannot tell.
// It may be related to this bug: https://bugs.llvm.org/show_bug.cgi?id=41311
va_copy(args_clone, *args); // NOLINT(clang-analyzer-valist.Uninitialized)
wjwwood marked this conversation as resolved.
Show resolved Hide resolved
status = rcutils_char_array_vsprintf(&msg_array, format, args_clone);
va_end(args_clone);

Expand Down
11 changes: 8 additions & 3 deletions rcl/src/rcl/logging_rosout.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@ rcl_ret_t rcl_logging_rosout_fini_publisher_for_node(

void rcl_logging_rosout_output_handler(
const rcutils_log_location_t * location,
int severity, const char * name, rcutils_time_point_value_t timestamp,
const char * format, va_list * args)
int severity,
const char * name,
rcutils_time_point_value_t timestamp,
const char * format,
va_list * args)
{
rosout_map_entry_t entry;
rcl_ret_t status = RCL_RET_OK;
Expand All @@ -251,7 +254,9 @@ void rcl_logging_rosout_output_handler(
};

va_list args_clone;
va_copy(args_clone, *args);
// The args are initialized, but clang-tidy cannot tell.
// It may be related to this bug: https://bugs.llvm.org/show_bug.cgi?id=41311
va_copy(args_clone, *args); // NOLINT(clang-analyzer-valist.Uninitialized)
wjwwood marked this conversation as resolved.
Show resolved Hide resolved
RCL_RET_FROM_RCUTIL_RET(status, rcutils_char_array_vsprintf(&msg_array, format, args_clone));
va_end(args_clone);
if (RCL_RET_OK != status) {
Expand Down