[libcxx-commits] [libcxx] [libcxx] Handle windows system error code mapping in std::error_code. (PR #93101)
James Y Knight via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 13 15:07:23 PDT 2024
================
@@ -300,15 +296,15 @@ inline int statvfs(const wchar_t* p, StatVFS* buf) {
break;
path parent = dir.parent_path();
if (parent == dir) {
- errno = ENOENT;
+ SetLastError(ERROR_PATH_NOT_FOUND);
----------------
jyknight wrote:
This function is now expected to report its error to the caller via `get_last_error()`. Formerly, it was expected to report its error to the caller via `errno`.
In most cases, the error is coming from the Windows API itself (e.g. the cases above), so it's already in the right place to be reported by get_last_error. Where it previously called `set_errno`, to convert from windows error code to errno, now doesn't need to do anything.
But, on this line, and a few places below, there is no underlying OS API call that is setting the error code. These cases formerly manually set errno, and now equivalently need to set the windows error code (via SetLastError).
https://github.com/llvm/llvm-project/pull/93101
More information about the libcxx-commits
mailing list