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

Address clang-tidy warnings #47

Merged
merged 2 commits into from
Feb 13, 2020
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
4 changes: 2 additions & 2 deletions ament_index_cpp/src/get_package_prefix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ format_package_not_found_error_message(const std::string & package_name)
for (const auto & path : search_paths) {
message += path + ", ";
}
if (search_paths.size() > 0) {
if (!search_paths.empty()) {
message = message.substr(0, message.size() - 2);
}
return message + "]";
Expand All @@ -43,7 +43,7 @@ PackageNotFoundError::PackageNotFoundError(const std::string & _package_name)
package_name(_package_name)
{}

PackageNotFoundError::~PackageNotFoundError() {}
PackageNotFoundError::~PackageNotFoundError() = default;

std::string
get_package_prefix(const std::string & package_name)
Expand Down
2 changes: 1 addition & 1 deletion ament_index_cpp/src/get_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ get_resource(
throw std::runtime_error("ament_index_cpp::get_resource() resource name must not be empty");
}
auto paths = get_search_paths();
for (auto path : paths) {
for (const auto & path : paths) {
auto resource_path = rcpputils::fs::path{path} / "share" / "ament_index" / "resource_index" /
resource_type / resource_name;
std::ifstream s(resource_path.string());
Expand Down
6 changes: 3 additions & 3 deletions ament_index_cpp/src/get_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#ifndef _WIN32
#include <dirent.h>
#include <errno.h>
#include <cerrno>
#else
#include <windows.h>
#endif
Expand All @@ -39,7 +39,7 @@ get_resources(const std::string & resource_type)
}
std::map<std::string, std::string> resources;
auto paths = get_search_paths();
for (auto base_path : paths) {
for (const auto & base_path : paths) {
auto path =
rcpputils::fs::path{base_path} / "share" / "ament_index" / "resource_index" / resource_type;

Expand All @@ -49,7 +49,7 @@ get_resources(const std::string & resource_type)
continue;
}
dirent * entry;
while ((entry = readdir(dir)) != NULL) {
while ((entry = readdir(dir)) != nullptr) {
// ignore directories
auto subdir = opendir((path / entry->d_name).string().c_str());
if (subdir) {
Expand Down
2 changes: 1 addition & 1 deletion ament_index_cpp/src/get_search_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ get_search_paths()
continue;
}
// skip non existing directories
struct stat s;
struct stat s {};
if (stat(tok.c_str(), &s)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion ament_index_cpp/src/has_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ has_resource(
throw std::runtime_error("ament_index_cpp::has_resource() resource name must not be empty");
}
auto paths = get_search_paths();
for (auto path : paths) {
for (const auto & path : paths) {
auto resource_path = rcpputils::fs::path{path} / "share" / "ament_index" / "resource_index" /
resource_type / resource_name;
std::ifstream s(resource_path.string());
Expand Down