diff options
author | Michael Pratt <mpratt@google.com> | 2019-01-23 18:23:39 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-23 18:24:48 -0800 |
commit | 74f5100a92854bb244f560847cd8f459a8a06688 (patch) | |
tree | 99b73597c811ff2603593ef5c8e1a394be51997b | |
parent | af89fb49af1c9112753c718eb8538bcd9d2a6c6c (diff) |
Fix cases of missing braces on if
PiperOrigin-RevId: 230641540
Change-Id: Icccc3cdeec191138940f0ecea0a29798359d2b1f
-rw-r--r-- | test/syscalls/linux/socket_inet_loopback.cc | 13 | ||||
-rw-r--r-- | test/util/fs_util.cc | 22 | ||||
-rw-r--r-- | test/util/posix_error.h | 4 |
3 files changed, 28 insertions, 11 deletions
diff --git a/test/syscalls/linux/socket_inet_loopback.cc b/test/syscalls/linux/socket_inet_loopback.cc index 0893be5a7..d83fb1543 100644 --- a/test/syscalls/linux/socket_inet_loopback.cc +++ b/test/syscalls/linux/socket_inet_loopback.cc @@ -261,7 +261,9 @@ TEST_P(SocketInetReusePortTest, TcpPortReuseMultiThread) { ASSERT_THAT(listen(fd, 40), SyscallSucceeds()); // On the first bind we need to determine which port was bound. - if (i != 0) continue; + if (i != 0) { + continue; + } // Get the port bound by the listening socket. socklen_t addrlen = listener.addr_len; @@ -363,7 +365,9 @@ TEST_P(SocketInetReusePortTest, UdpPortReuseMultiThread) { SyscallSucceeds()); // On the first bind we need to determine which port was bound. - if (i != 0) continue; + if (i != 0) { + continue; + } // Get the port bound by the listening socket. socklen_t addrlen = listener.addr_len; @@ -1087,10 +1091,11 @@ TEST_P(SocketMultiProtocolInetLoopbackTest, PortReuseTwoSockets) { // Verify that two sockets can be bound to the same port only if // SO_REUSEPORT is set for both of them. - if (!portreuse1 || !portreuse2) + if (!portreuse1 || !portreuse2) { ASSERT_THAT(ret, SyscallFailsWithErrno(EADDRINUSE)); - else + } else { ASSERT_THAT(ret, SyscallSucceeds()); + } } } } diff --git a/test/util/fs_util.cc b/test/util/fs_util.cc index e7e8be1d8..6bd424417 100644 --- a/test/util/fs_util.cc +++ b/test/util/fs_util.cc @@ -550,25 +550,35 @@ std::pair<absl::string_view, absl::string_view> SplitPath( std::string::size_type pos = path.find_last_of('/'); // Handle the case with no '/' in 'path'. - if (pos == absl::string_view::npos) + if (pos == absl::string_view::npos) { return std::make_pair(path.substr(0, 0), path); + } // Handle the case with a single leading '/' in 'path'. - if (pos == 0) + if (pos == 0) { return std::make_pair(path.substr(0, 1), absl::ClippedSubstr(path, 1)); + } return std::make_pair(path.substr(0, pos), absl::ClippedSubstr(path, pos + 1)); } std::string JoinPath(absl::string_view path1, absl::string_view path2) { - if (path1.empty()) return std::string(path2); - if (path2.empty()) return std::string(path1); + if (path1.empty()) { + return std::string(path2); + } + if (path2.empty()) { + return std::string(path1); + } + if (path1.back() == '/') { - if (path2.front() == '/') + if (path2.front() == '/') { return absl::StrCat(path1, absl::ClippedSubstr(path2, 1)); + } } else { - if (path2.front() != '/') return absl::StrCat(path1, "/", path2); + if (path2.front() != '/') { + return absl::StrCat(path1, "/", path2); + } } return absl::StrCat(path1, path2); } diff --git a/test/util/posix_error.h b/test/util/posix_error.h index 7fafe01b5..c3306b015 100644 --- a/test/util/posix_error.h +++ b/test/util/posix_error.h @@ -426,7 +426,9 @@ IsPosixErrorOkAndHolds(InnerMatcher&& inner_matcher) { #define RETURN_IF_ERRNO(s) \ do { \ - if (!s.ok()) return s; \ + if (!s.ok()) { \ + return s; \ + } \ } while (false); #define ASSERT_NO_ERRNO_AND_VALUE(expr) \ |