From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id E1644396AC2F; Mon, 15 Feb 2021 15:52:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1644396AC2F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-7247] libstdc++: Add missing return and use reserved name X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: abe07a74bb7a2692eff2af151ca54e749ed5eba6 X-Git-Newrev: d27153f038c2f39ed1b7e6ba9dab59f88b8ca245 Message-Id: <20210215155230.E1644396AC2F@sourceware.org> Date: Mon, 15 Feb 2021 15:52:30 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2021 15:52:31 -0000 https://gcc.gnu.org/g:d27153f038c2f39ed1b7e6ba9dab59f88b8ca245 commit r11-7247-gd27153f038c2f39ed1b7e6ba9dab59f88b8ca245 Author: Jonathan Wakely Date: Mon Feb 15 14:00:36 2021 +0000 libstdc++: Add missing return and use reserved name The once_flag::_M_activate() function is only ever called immediately after a call to once_flag::_M_passive(), and so in the non-gthreads case it is impossible for _M_passive() to be true in the body of _M_activate(). Add a check for it anyway, to avoid warnings about missing return. Also replace a non-reserved name with a reserved one. libstdc++-v3/ChangeLog: * include/std/mutex (once_flag::_M_activate()): Add explicit return statement for passive case. (once_flag::_M_finish(bool)): Use reserved name for parameter. Diff: --- libstdc++-v3/include/std/mutex | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index 25e580cf0fc..f96c48e88ec 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -706,6 +706,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool _M_activate(); // Must be called to complete an active execution. + // The argument is true if the active execution was a returning execution, + // false if it was an exceptional execution. void _M_finish(bool __returning) noexcept; // RAII helper to call _M_finish. @@ -742,18 +744,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline bool once_flag::_M_activate() { - if (_M_once == _Bits::_Init) + if (_M_once == _Bits::_Init) [[__likely__]] { _M_once = _Bits::_Active; return true; } - else if (!_M_passive()) + else if (_M_passive()) // Caller should have checked this already. + return false; + else __throw_system_error(EDEADLK); } inline void - once_flag::_M_finish(bool returning) noexcept - { _M_once = returning ? _Bits::_Done : _Bits::_Init; } + once_flag::_M_finish(bool __returning) noexcept + { _M_once = __returning ? _Bits::_Done : _Bits::_Init; } #elif defined _GLIBCXX_HAVE_LINUX_FUTEX