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

Fixed the build #449

Merged
merged 2 commits into from
May 30, 2019
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
3 changes: 2 additions & 1 deletion src/common/base/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ Status Configuration::parseFromFile(const std::string &filename) {
// read the whole content
// TODO(dutor) ::read might be interrupted by signals
auto buffer = std::make_unique<char[]>(len + 1);
::read(fd, buffer.get(), len);
auto charsRead = ::read(fd, buffer.get(), len);
UNUSED(charsRead);
buffer[len] = '\0';
// strip off all comments
static const std::regex comment("//.*|#.*");
Expand Down
11 changes: 10 additions & 1 deletion src/common/network/NetworkUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,16 @@ bool NetworkUtils::getDynamicPortRange(uint16_t& low, uint16_t& high) {
return false;
}

fscanf(pipe, "%hu %hu", &low, &high);
if (fscanf(pipe, "%hu %hu", &low, &high) != 2) {
LOG(ERROR) << "Failed to read from /proc/sys/net/ipv4/ip_local_port_range";
// According to ICANN, the port range is devided into three sections
//
// Well-known ports: 0 to 1023 (used for system services)
// Registered/user ports: 1024 to 49151
// Dynamic/private ports: 49152 to 65535
low = 49152;
high = 65535;
}

if (pclose(pipe) < 0) {
LOG(ERROR) << "Failed to close the pipe: " << strerror(errno);
Expand Down
3 changes: 2 additions & 1 deletion src/common/network/test/NetworkUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ TEST(NetworkUtils, getHostname) {

FILE* fp = popen("LD_PRELOAD= hostname | tr -d ['\n']", "r");
char buffer[256];
fgets(buffer, sizeof(buffer), fp);
auto numChars = fgets(buffer, sizeof(buffer), fp);
UNUSED(numChars);
pclose(fp);
EXPECT_EQ(std::string(buffer), hostname);
}
Expand Down
3 changes: 2 additions & 1 deletion src/common/process/test/ProcessTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ TEST(ProcessUtils, getExeCWD) {
auto result = ProcessUtils::getExeCWD();
ASSERT_TRUE(result.ok()) << result.status();
char buffer[PATH_MAX];
::getcwd(buffer, sizeof(buffer));
auto len = ::getcwd(buffer, sizeof(buffer));
UNUSED(len);
ASSERT_EQ(buffer, result.value());
}

Expand Down