зеркало из https://github.com/microsoft/STL.git
New BOOL rules (#2815)
This commit is contained in:
Родитель
bda3b9aa61
Коммит
be74e53d83
|
@ -537,7 +537,7 @@ struct _Init_once_completer {
|
|||
once_flag& _Once;
|
||||
unsigned long _DwFlags;
|
||||
~_Init_once_completer() {
|
||||
if (_RENAME_WINDOWS_API(__std_init_once_complete)(&_Once._Opaque, _DwFlags, nullptr) == 0) {
|
||||
if (!_RENAME_WINDOWS_API(__std_init_once_complete)(&_Once._Opaque, _DwFlags, nullptr)) {
|
||||
__std_init_once_link_alternate_names_and_abort();
|
||||
}
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ void(call_once)(once_flag& _Once, _Fn&& _Fx, _Args&&... _Ax) noexcept(
|
|||
// call _Fx(_Ax...) once
|
||||
// parentheses against common "#define call_once(flag,func) pthread_once(flag,func)"
|
||||
int _Pending;
|
||||
if (_RENAME_WINDOWS_API(__std_init_once_begin_initialize)(&_Once._Opaque, 0, &_Pending, nullptr) == 0) {
|
||||
if (!_RENAME_WINDOWS_API(__std_init_once_begin_initialize)(&_Once._Opaque, 0, &_Pending, nullptr)) {
|
||||
_CSTD abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,10 @@ struct once_flag { // opaque data structure for call_once()
|
|||
void* _Opaque;
|
||||
};
|
||||
|
||||
// Returns BOOL, nonzero to indicate success, zero for failure
|
||||
using _Execute_once_fp_t = int(__stdcall*)(void*, void*, void**);
|
||||
|
||||
// Returns BOOL, nonzero to indicate success, zero for failure
|
||||
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Execute_once(
|
||||
once_flag& _Flag, _Execute_once_fp_t _Callback, void* _Pv) noexcept;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ extern "C" int __cdecl __crtCompareStringA(_In_z_ LPCWSTR LocaleName, _In_ DWORD
|
|||
// - if the one count is a naked lead byte, the strings are equal
|
||||
// - otherwise it is a single character and they are unequal
|
||||
CPINFO cpInfo;
|
||||
if (GetCPInfo(code_page, &cpInfo) == FALSE) {
|
||||
if (!GetCPInfo(code_page, &cpInfo)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ _CRTIMP2_PURE int _Thrd_start(_Thrd_t* thr, _Thrd_callback_t func, void* b) { //
|
|||
|
||||
int _Thrd_join(_Thrd_t thr, int* code) { // return exit code when thread terminates
|
||||
unsigned long res;
|
||||
if (WaitForSingleObjectEx(thr._Hnd, INFINITE, FALSE) == WAIT_FAILED || GetExitCodeThread(thr._Hnd, &res) == 0) {
|
||||
if (WaitForSingleObjectEx(thr._Hnd, INFINITE, FALSE) == WAIT_FAILED || !GetExitCodeThread(thr._Hnd, &res)) {
|
||||
return _Thrd_error;
|
||||
}
|
||||
|
||||
|
@ -62,11 +62,11 @@ int _Thrd_join(_Thrd_t thr, int* code) { // return exit code when thread termina
|
|||
*code = static_cast<int>(res);
|
||||
}
|
||||
|
||||
return CloseHandle(thr._Hnd) == 0 ? _Thrd_error : _Thrd_success;
|
||||
return CloseHandle(thr._Hnd) ? _Thrd_success : _Thrd_error;
|
||||
}
|
||||
|
||||
int _Thrd_detach(_Thrd_t thr) { // tell OS to release thread's resources when it terminates
|
||||
return CloseHandle(thr._Hnd) == 0 ? _Thrd_error : _Thrd_success;
|
||||
return CloseHandle(thr._Hnd) ? _Thrd_success : _Thrd_error;
|
||||
}
|
||||
|
||||
void _Thrd_sleep(const xtime* xt) { // suspend thread until time xt
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace {
|
|||
_Ty& _Immortalize() { // return a reference to an object that will live forever
|
||||
static once_flag _Flag;
|
||||
alignas(_Ty) static unsigned char _Storage[sizeof(_Ty)];
|
||||
if (_Execute_once(_Flag, _Immortalize_impl<_Ty>, &_Storage) == 0) {
|
||||
if (!_Execute_once(_Flag, _Immortalize_impl<_Ty>, &_Storage)) {
|
||||
// _Execute_once should never fail if the callback never fails
|
||||
_STD terminate();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ extern "C" [[nodiscard]] __std_win_error __stdcall __std_get_cvt(
|
|||
|
||||
CPINFOEXW _Info{};
|
||||
const DWORD _Flags = 0; // reserved, must be zero
|
||||
if (GetCPInfoExW(static_cast<UINT>(_Codepage), _Flags, &_Info) == 0) {
|
||||
if (!GetCPInfoExW(static_cast<UINT>(_Codepage), _Flags, &_Info)) {
|
||||
// NB: the only documented failure mode for GetCPInfoExW is ERROR_INVALID_PARAMETER,
|
||||
// so in practice it should never fail for CP_ACP.
|
||||
return __std_win_error{GetLastError()};
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Concurrency {
|
|||
return nullptr;
|
||||
#else // ^^^ defined(_CRT_APP) ^^^ // vvv !defined(_CRT_APP) vvv
|
||||
HMODULE _Result;
|
||||
if (::GetModuleHandleExW(_Flags, _Addr, &_Result) == 0) {
|
||||
if (!GetModuleHandleExW(_Flags, _Addr, &_Result)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче