From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 31C2D396AC35 for ; Mon, 15 Feb 2021 15:52:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 31C2D396AC35 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-qwiuMoAgNrCl3bDF9dgt4Q-1; Mon, 15 Feb 2021 10:52:47 -0500 X-MC-Unique: qwiuMoAgNrCl3bDF9dgt4Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EBE5814305; Mon, 15 Feb 2021 15:52:46 +0000 (UTC) Received: from localhost (unknown [10.33.36.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id B86A75D9C0; Mon, 15 Feb 2021 15:52:45 +0000 (UTC) Date: Mon, 15 Feb 2021 15:52:44 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add missing return and use reserved name Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="4QYYZqy1LtKz7bSb" Content-Disposition: inline X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2021 15:52:52 -0000 --4QYYZqy1LtKz7bSb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. Tested x86_64-linux. Committed to trunk. --4QYYZqy1LtKz7bSb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit d27153f038c2f39ed1b7e6ba9dab59f88b8ca245 Author: Jonathan Wakely Date: Mon Feb 15 14:00:36 2021 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 --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 --4QYYZqy1LtKz7bSb--