mirror of
https://github.com/boostorg/filesystem.git
synced 2025-05-12 13:41:47 +00:00
Changed suppression of signed/unsigned mismatch to explicit casts.
Turns out, suppressing -Wsign-compare doesn't work on gcc 8 in MinGW-w64 at least in one instance. So we have to do it the hard way and explicitly cast NTSTATUS values on every comparison.
This commit is contained in:
parent
bfb06365b3
commit
5dc58be3cd
@ -799,7 +799,7 @@ system::error_code dir_itr_increment(dir_itr_imp& imp, fs::path& filename, fs::f
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
dir_itr_close(imp);
|
||||
if (status == STATUS_NO_MORE_FILES)
|
||||
if (BOOST_NTSTATUS_EQ(status, STATUS_NO_MORE_FILES))
|
||||
goto done;
|
||||
|
||||
return system::error_code(translate_ntstatus(status), system::system_category());
|
||||
@ -1047,7 +1047,7 @@ system::error_code dir_itr_create(boost::intrusive_ptr< detail::dir_itr_imp >& i
|
||||
// causes a ERROR_FILE_NOT_FOUND error returned from FindFirstFileW
|
||||
// (which is presumably equivalent to STATUS_NO_SUCH_FILE) which we
|
||||
// do not consider an error. It is treated as eof instead.
|
||||
if (status == STATUS_NO_MORE_FILES || status == STATUS_NO_SUCH_FILE)
|
||||
if (BOOST_NTSTATUS_EQ(status, STATUS_NO_MORE_FILES) || BOOST_NTSTATUS_EQ(status, STATUS_NO_SUCH_FILE))
|
||||
goto done;
|
||||
|
||||
return error_code(translate_ntstatus(status), system_category());
|
||||
@ -1520,7 +1520,7 @@ void recursive_directory_iterator_increment(recursive_directory_iterator& it, sy
|
||||
{
|
||||
symlink_ft = detail::status_by_handle(direntry_handle.get(), dir_it->path(), &ec).type();
|
||||
}
|
||||
else if (status == STATUS_NOT_IMPLEMENTED)
|
||||
else if (BOOST_NTSTATUS_EQ(status, STATUS_NOT_IMPLEMENTED))
|
||||
{
|
||||
symlink_ft = dir_it->symlink_file_type(ec);
|
||||
}
|
||||
@ -1615,7 +1615,7 @@ void recursive_directory_iterator_increment(recursive_directory_iterator& it, sy
|
||||
{
|
||||
goto get_file_type_by_handle;
|
||||
}
|
||||
else if (status == STATUS_NOT_IMPLEMENTED)
|
||||
else if (BOOST_NTSTATUS_EQ(status, STATUS_NOT_IMPLEMENTED))
|
||||
{
|
||||
ft = dir_it->file_type(ec);
|
||||
}
|
||||
|
@ -51,11 +51,9 @@ typedef boost::winapi::DWORD_ err_t;
|
||||
#define BOOST_ERROR_ALREADY_EXISTS boost::winapi::ERROR_ALREADY_EXISTS_
|
||||
#define BOOST_ERROR_NOT_SUPPORTED boost::winapi::ERROR_NOT_SUPPORTED_
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// STATUS_* constants defined in ntstatus.h are defined as DWORDs, and NTSTATUS is long. This results
|
||||
// in signed/unsigned mismatch warnings emitted by gcc and clang. Consider that a platform bug.
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#endif
|
||||
// STATUS_* constants defined in ntstatus.h in some SDKs are defined as DWORDs, and NTSTATUS is LONG.
|
||||
// This results in signed/unsigned mismatch warnings emitted by gcc and clang. Consider that a platform bug.
|
||||
#define BOOST_NTSTATUS_EQ(x, y) static_cast< boost::winapi::ULONG_ >(x) == static_cast< boost::winapi::ULONG_ >(y)
|
||||
|
||||
// Note: Legacy MinGW doesn't have ntstatus.h and doesn't define NTSTATUS error codes other than STATUS_SUCCESS.
|
||||
#if !defined(NT_SUCCESS)
|
||||
@ -177,8 +175,9 @@ inline boost::winapi::DWORD_ translate_ntstatus(boost::winapi::NTSTATUS_ status)
|
||||
//! Tests if the NTSTATUS indicates that the file is not found
|
||||
inline bool not_found_ntstatus(boost::winapi::NTSTATUS_ status) noexcept
|
||||
{
|
||||
return status == STATUS_NO_SUCH_FILE || status == STATUS_OBJECT_NAME_NOT_FOUND || status == STATUS_OBJECT_PATH_NOT_FOUND ||
|
||||
status == STATUS_BAD_NETWORK_PATH || status == STATUS_BAD_NETWORK_NAME;
|
||||
return BOOST_NTSTATUS_EQ(status, STATUS_NO_SUCH_FILE) || BOOST_NTSTATUS_EQ(status, STATUS_OBJECT_NAME_NOT_FOUND) ||
|
||||
BOOST_NTSTATUS_EQ(status, STATUS_OBJECT_PATH_NOT_FOUND) || BOOST_NTSTATUS_EQ(status, STATUS_BAD_NETWORK_PATH) ||
|
||||
BOOST_NTSTATUS_EQ(status, STATUS_BAD_NETWORK_NAME);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1559,7 +1559,7 @@ boost::winapi::NTSTATUS_ nt_create_file_handle_at
|
||||
{
|
||||
NtCreateFile_t* nt_create_file = filesystem::detail::atomic_load_relaxed(nt_create_file_api);
|
||||
if (BOOST_UNLIKELY(!nt_create_file))
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
return static_cast< boost::winapi::NTSTATUS_ >(STATUS_NOT_IMPLEMENTED);
|
||||
|
||||
unicode_string obj_name = {};
|
||||
obj_name.Buffer = const_cast< wchar_t* >(p.c_str());
|
||||
@ -1591,7 +1591,7 @@ boost::winapi::NTSTATUS_ nt_create_file_handle_at
|
||||
0u // EaLength
|
||||
);
|
||||
|
||||
if (BOOST_UNLIKELY(status == STATUS_INVALID_PARAMETER && (obj_attrs.Attributes & OBJ_DONT_REPARSE) != 0u))
|
||||
if (BOOST_UNLIKELY(BOOST_NTSTATUS_EQ(status, STATUS_INVALID_PARAMETER) && (obj_attrs.Attributes & OBJ_DONT_REPARSE) != 0u))
|
||||
{
|
||||
// OBJ_DONT_REPARSE is supported since Windows 10, retry without it
|
||||
filesystem::detail::atomic_store_relaxed(g_no_obj_dont_reparse, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user