From 4fc78b5e3fea531db48d71939d39c1d32b4b464d Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 27 Feb 2023 10:35:58 -0800 Subject: [PATCH 1/3] Drop `break;` after `return true;` in ppltasks.cpp. --- stl/src/ppltasks.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/stl/src/ppltasks.cpp b/stl/src/ppltasks.cpp index de405dd6cfb..95c62ab08ee 100644 --- a/stl/src/ppltasks.cpp +++ b/stl/src/ppltasks.cpp @@ -306,7 +306,6 @@ namespace Concurrency { case APTTYPE_STA: case APTTYPE_MAINSTA: return true; - break; case APTTYPE_NA: switch (_AptTypeQualifier) { // A thread executing in a neutral apartment is either STA or MTA. To find out if this thread is @@ -316,7 +315,6 @@ namespace Concurrency { case APTTYPEQUALIFIER_NA_ON_STA: case APTTYPEQUALIFIER_NA_ON_MAINSTA: return true; - break; } break; } From ccb25644ffe16aaa58f140253eb19f5b88f53e1f Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 2 Mar 2023 07:47:32 -0800 Subject: [PATCH 2/3] In gcd(), fuse break followed by return. There's no other way out of this infinite loop. --- stl/inc/numeric | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stl/inc/numeric b/stl/inc/numeric index 3eb15576da1..f9479b6ccc3 100644 --- a/stl/inc/numeric +++ b/stl/inc/numeric @@ -623,12 +623,11 @@ _NODISCARD constexpr common_type_t<_Mt, _Nt> gcd(const _Mt _Mx, const _Nt _Nx) n _Nx_magnitude -= _Mx_magnitude; if (_Nx_magnitude == 0U) { - break; + return static_cast<_Common>(_Mx_magnitude << _Common_factors_of_2); } _Nx_trailing_zeroes = static_cast(_Countr_zero_impl(_Nx_magnitude)); } - return static_cast<_Common>(_Mx_magnitude << _Common_factors_of_2); }); } From 418e12aeb3b4c6dbd6aace09cad38f77f140e9fc Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 2 Mar 2023 07:43:49 -0800 Subject: [PATCH 3/3] fiopen.cpp: Change `ios_base::openmode atendflag` to `const bool at_end`. We don't modify it, and it's simpler to immediately boil it down to a bool. --- stl/src/fiopen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/src/fiopen.cpp b/stl/src/fiopen.cpp index 51f8c24cc57..7c6d3eecbb3 100644 --- a/stl/src/fiopen.cpp +++ b/stl/src/fiopen.cpp @@ -50,8 +50,8 @@ namespace { ios_base::out | ios_base::in | ios_base::trunc | ios_base::binary | ios_base::_Noreplace, }; - FILE* fp = nullptr; - ios_base::openmode atendflag = mode & ios_base::ate; + FILE* fp = nullptr; + const bool at_end = (mode & ios_base::ate) != 0; if (mode & ios_base::_Nocreate) { mode |= ios_base::in; // file must exist @@ -75,7 +75,7 @@ namespace { return nullptr; // open failed } - if (atendflag && fseek(fp, 0, SEEK_END) != 0) { + if (at_end && fseek(fp, 0, SEEK_END) != 0) { fclose(fp); // can't position at end return nullptr; }