system/Error: use std::generic_category() for errno on Windows
It's wrong to use std::system_category() for both GetLastError() and errno on Windows. Apparently, everybody uses std::generic_category() for errno values, which appears to be a safe choice. Some discussion on this confusing topic can be found here: https://stackoverflow.com/questions/28746372/system-error-categories-and-standard-system-error-codes
This commit is contained in:
@@ -21,8 +21,7 @@
|
||||
#include "FlacIOHandle.hxx"
|
||||
#include "Log.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <system_error>
|
||||
#include "system/Error.hxx"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -49,7 +48,7 @@ FlacIORead(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle)
|
||||
|
||||
#ifndef WIN32
|
||||
} catch (const std::system_error &e) {
|
||||
errno = e.code().category() == std::system_category()
|
||||
errno = e.code().category() == ErrnoCategory()
|
||||
? e.code().value()
|
||||
/* just some random non-zero errno
|
||||
value */
|
||||
|
Reference in New Issue
Block a user