summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2023-04-19 22:00:38 +0200
committerJoel Rosdahl <joel@rosdahl.net>2023-04-19 22:03:01 +0200
commit4d7c6f7d5a73a15d6e6e2cad2ce2907dde14c049 (patch)
tree0bb2a8f903d05bb745a832a3a6d9cbd12efdec73
parent8a72cde9ad9ac78b013e2d2ff7657637b4d08f46 (diff)
downloadccache-4d7c6f7d5a73a15d6e6e2cad2ce2907dde14c049.tar.gz
refactor: Use constructor member initializer lists
As suggested by clang-tidy (cppcoreguidelines-prefer-member-initializer).
-rw-r--r--src/File.hpp6
-rw-r--r--src/Stat.cpp4
2 files changed, 4 insertions, 6 deletions
diff --git a/src/File.hpp b/src/File.hpp
index eea2c09c..5ace5704 100644
--- a/src/File.hpp
+++ b/src/File.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
@@ -46,10 +46,8 @@ private:
bool m_owned = false;
};
-inline File::File(FILE* const file)
+inline File::File(FILE* const file) : m_file(file), m_owned(false)
{
- m_file = file;
- m_owned = false;
}
inline File::File(const std::string& path, const char* mode)
diff --git a/src/Stat.cpp b/src/Stat.cpp
index 87b20203..15293e12 100644
--- a/src/Stat.cpp
+++ b/src/Stat.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
@@ -206,8 +206,8 @@ win32_lstat(const char* path, Stat::stat_t* st)
Stat::Stat(StatFunction stat_function,
const std::string& path,
Stat::OnError on_error)
+ : m_path(path)
{
- m_path = path;
int result = stat_function(path.c_str(), &m_stat);
if (result == 0) {
m_errno = 0;