Skip to content

Commit a68f7ae

Browse files
committed
PR feedback
Signed-off-by: Scott K Logan <[email protected]>
1 parent ee6a8dc commit a68f7ae

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

rcl_logging_spdlog/test/fixtures.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <rcutils/process.h>
2323
#include <rcutils/types/string_array.h>
2424

25+
#include <limits.h>
2526
#include <string>
2627

2728
#include "gtest/gtest.h"
@@ -89,7 +90,11 @@ class LoggingTest : public AllocatorTest
8990
throw std::runtime_error("Failed to glob for log files");
9091
}
9192

92-
char raw_line[2048];
93+
#ifdef _WIN32
94+
char raw_line[MAX_PATH];
95+
#else
96+
char raw_line[PATH_MAX];
97+
#endif
9398
char * ret = fgets(raw_line, sizeof(raw_line), fp);
9499
pclose(fp);
95100
if (nullptr == ret) {

rcl_logging_spdlog/test/test_logging_interface.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <rcutils/error_handling.h>
2020
#include <rcutils/logging.h>
2121

22+
#include <limits.h>
2223
#include <fstream>
2324
#include <string>
2425

@@ -64,24 +65,22 @@ class RestoreEnvVar
6465
// TODO(cottsay): Remove when ros2/rcpputils#63 is resolved
6566
static fs::path current_path()
6667
{
67-
char * cwd;
6868
#ifdef _WIN32
6969
#ifdef UNICODE
7070
#error "rcpputils::fs does not support Unicode paths"
7171
#endif
72-
cwd = _getcwd(NULL, 0);
72+
char cwd[MAX_PATH];
73+
if (nullptr == _getcwd(cwd, MAX_PATH)) {
7374
#else
74-
cwd = getcwd(NULL, 0);
75+
char cwd[PATH_MAX];
76+
if (nullptr == getcwd(cwd, PATH_MAX)) {
7577
#endif
76-
if (nullptr == cwd) {
7778
std::error_code ec{errno, std::system_category()};
7879
errno = 0;
7980
throw std::system_error{ec, "cannot get current working directory"};
8081
}
8182

82-
std::string ret(cwd);
83-
free(cwd);
84-
return fs::path(ret);
83+
return fs::path(cwd);
8584
}
8685

8786
TEST_F(LoggingTest, init_invalid)

0 commit comments

Comments
 (0)