From: Joel Rosdahl Date: Tue, 26 Apr 2022 18:54:29 +0000 (+0200) Subject: fix: Make Stat::same_inode_as consider error code X-Git-Tag: v4.6.1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f4b6d6fc0a6c60e28d66178a53010a602b87280;p=thirdparty%2Fccache.git fix: Make Stat::same_inode_as consider error code --- diff --git a/src/Stat.hpp b/src/Stat.hpp index 2f56214a5..47a085481 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 9253f6857..3a3586e29 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")