public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r9-9376] libstdc++: Use correct error category for Windows error codes Date: Tue, 20 Apr 2021 18:52:55 +0000 (GMT) [thread overview] Message-ID: <20210420185255.25E9F388A437@sourceware.org> (raw) https://gcc.gnu.org/g:4160c7da622cf5032296b72ef9e43bf6548dd25a commit r9-9376-g4160c7da622cf5032296b72ef9e43bf6548dd25a Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Feb 10 16:45:38 2021 +0000 libstdc++: Use correct error category for Windows error codes When the result of GetLastError() is stored in a std::error_code it should use std::system_category(), not std::generic_category() that is used for POSIX errno values. libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc (fs::create_hard_link, fs::equivalent) (fs::remove): Use std::system_category() for error codes from GetLastError(). * src/filesystem/ops.cc (fs::create_hard_link, fs::remove): Likewise. (cherry picked from commit 313e2dc377d07d5fae5a3fd666ad7000d7e8771d) Diff: --- libstdc++-v3/src/c++17/fs_ops.cc | 8 ++++---- libstdc++-v3/src/filesystem/ops.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/src/c++17/fs_ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc index 402ed02143d..f744d2f7b56 100644 --- a/libstdc++-v3/src/c++17/fs_ops.cc +++ b/libstdc++-v3/src/c++17/fs_ops.cc @@ -690,7 +690,7 @@ fs::create_hard_link(const path& to, const path& new_hard_link, if (CreateHardLinkW(new_hard_link.c_str(), to.c_str(), NULL)) ec.clear(); else - ec.assign((int)GetLastError(), generic_category()); + ec.assign((int)GetLastError(), system_category()); #else ec = std::make_error_code(std::errc::not_supported); #endif @@ -882,12 +882,12 @@ fs::equivalent(const path& p1, const path& p2, error_code& ec) noexcept if (!h1 || !h2) { if (!h1 && !h2) - ec.assign((int)GetLastError(), generic_category()); + ec.assign((int)GetLastError(), system_category()); return false; } if (!h1.get_info() || !h2.get_info()) { - ec.assign((int)GetLastError(), generic_category()); + ec.assign((int)GetLastError(), system_category()); return false; } return h1.info.dwVolumeSerialNumber == h2.info.dwVolumeSerialNumber @@ -1263,7 +1263,7 @@ fs::remove(const path& p, error_code& ec) noexcept return true; } else if (!ec) - ec.assign((int)GetLastError(), generic_category()); + ec.assign((int)GetLastError(), system_category()); } else if (status_known(st)) ec.clear(); diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index 0115cff1907..4859b6e7fa6 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -590,7 +590,7 @@ fs::create_hard_link(const path& to, const path& new_hard_link, if (CreateHardLinkW(new_hard_link.c_str(), to.c_str(), NULL)) ec.clear(); else - ec.assign((int)GetLastError(), generic_category()); + ec.assign((int)GetLastError(), system_category()); #else ec = std::make_error_code(std::errc::not_supported); #endif @@ -1062,7 +1062,7 @@ fs::remove(const path& p, error_code& ec) noexcept return true; } else if (!ec) - ec.assign((int)GetLastError(), generic_category()); + ec.assign((int)GetLastError(), system_category()); } else if (status_known(st)) ec.clear();
reply other threads:[~2021-04-20 18:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210420185255.25E9F388A437@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).