From acf519a77b480e8d974186568bd66eaa89bac024 Mon Sep 17 00:00:00 2001 From: Ting-Yu Wang Date: Tue, 23 Jun 2020 17:43:02 -0700 Subject: Nit fix: Create and use a std::string object for `const char*`. PiperOrigin-RevId: 317973144 --- test/syscalls/linux/proc.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'test/syscalls') 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) { -- cgit v1.2.3