Skip to content

Commit

Permalink
Merge pull request #168 from ros2/avoid_compiler_warning
Browse files Browse the repository at this point in the history
Avoid unused return value warning
  • Loading branch information
esteve committed Dec 4, 2015
2 parents 13d36a1 + f0fd292 commit 67dcd9f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rclcpp/src/rclcpp/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,18 @@ rclcpp::utilities::init(int argc, char * argv[])
// NOLINTNEXTLINE(runtime/arrays)
char error_string[error_length];
#ifndef _WIN32
strerror_r(errno, error_string, error_length);
#ifdef _GNU_SOURCE
char * msg = strerror_r(errno, error_string, error_length);
if (msg != error_string) {
strncpy(error_string, msg, error_length);
msg[error_length - 1] = '\0';
}
#else
int error_status = strerror_r(errno, error_string, error_length);
if (error_status != 0) {
throw std::runtime_error("Failed to get error string for errno: " + std::to_string(errno));
}
#endif
#else
strerror_s(error_string, error_length, errno);
#endif
Expand Down

0 comments on commit 67dcd9f

Please sign in to comment.