summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTing-Yu Wang <anivia@google.com>2020-06-23 17:43:02 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-23 17:44:34 -0700
commitacf519a77b480e8d974186568bd66eaa89bac024 (patch)
tree258abd542e7db9503e4fae8b8a2df7209cce9494
parent0c628c3152a727fff287a98897d83ee45ad990e5 (diff)
Nit fix: Create and use a std::string object for `const char*`.
PiperOrigin-RevId: 317973144
-rw-r--r--test/syscalls/linux/proc.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/test/syscalls/linux/proc.cc b/test/syscalls/linux/proc.cc
index da8f30f32..e77e9820e 100644
--- a/test/syscalls/linux/proc.cc
+++ b/test/syscalls/linux/proc.cc
@@ -1982,24 +1982,26 @@ void CheckDuplicatesRecursively(std::string path) {
break; // We're done.
}
- if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) {
+ const std::string name = dp->d_name;
+
+ if (name == "." || name == "..") {
continue;
}
// Ignore a duplicate entry if it isn't the last attempt.
if (i == max_attempts - 1) {
- ASSERT_EQ(children.find(std::string(dp->d_name)), children.end())
- << absl::StrCat(path, "/", dp->d_name);
- } else if (children.find(std::string(dp->d_name)) != children.end()) {
+ ASSERT_EQ(children.find(name), children.end())
+ << absl::StrCat(path, "/", name);
+ } else if (children.find(name) != children.end()) {
std::cerr << "Duplicate entry: " << i << ":"
- << absl::StrCat(path, "/", dp->d_name) << std::endl;
+ << absl::StrCat(path, "/", name) << std::endl;
success = false;
break;
}
- children.insert(std::string(dp->d_name));
+ children.insert(name);
if (dp->d_type == DT_DIR) {
- child_dirs.push_back(std::string(dp->d_name));
+ child_dirs.push_back(name);
}
}
if (success) {