diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2022-04-26 20:54:29 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2022-04-26 21:23:32 +0200 |
commit | 3f4b6d6fc0a6c60e28d66178a53010a602b87280 (patch) | |
tree | e0c910f3229c02ede0d18b76b6ee840e6ea9715c | |
parent | 0b157fabbf13103c90b49a921e1072c47858d116 (diff) | |
download | ccache-3f4b6d6fc0a6c60e28d66178a53010a602b87280.tar.gz |
fix: Make Stat::same_inode_as consider error code
-rw-r--r-- | src/Stat.hpp | 4 | ||||
-rw-r--r-- | unittest/test_Stat.cpp | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/Stat.hpp b/src/Stat.hpp index 2f56214a..47a08548 100644 --- a/src/Stat.hpp +++ b/src/Stat.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2021 Joel Rosdahl and other contributors +// Copyright (C) 2019-2022 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -171,7 +171,7 @@ inline Stat::operator bool() const inline bool Stat::same_inode_as(const Stat& other) const { - return device() == other.device() && inode() == other.inode(); + return m_errno == 0 && device() == other.device() && inode() == other.inode(); } inline int diff --git a/unittest/test_Stat.cpp b/unittest/test_Stat.cpp index 9253f685..3a3586e2 100644 --- a/unittest/test_Stat.cpp +++ b/unittest/test_Stat.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2021 Joel Rosdahl and other contributors +// Copyright (C) 2019-2022 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -197,6 +197,8 @@ TEST_CASE("Same i-node as") Util::write_file("a", "change size"); auto new_a_stat = Stat::stat("a"); CHECK(new_a_stat.same_inode_as(a_stat)); + + CHECK(!Stat::stat("nonexistent").same_inode_as(Stat::stat("nonexistent"))); } TEST_CASE("Return values when file is missing") |