From patchwork Wed Feb 27 22:18:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31676 Received: (qmail 52446 invoked by alias); 27 Feb 2019 22:28:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 52426 invoked by uid 89); 27 Feb 2019 22:28:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 22:28:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A6672116759; Wed, 27 Feb 2019 17:18:17 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ThkF4FzlTXip; Wed, 27 Feb 2019 17:18:17 -0500 (EST) Received: from murgatroyd.Home (75-166-85-218.hlrn.qwest.net [75.166.85.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 5120C116120; Wed, 27 Feb 2019 17:18:17 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/7] Add ATTRIBUTE_UNUSED_RESULT to scoped_mmap Date: Wed, 27 Feb 2019 15:18:11 -0700 Message-Id: <20190227221814.17661-5-tromey@adacore.com> In-Reply-To: <20190227221814.17661-1-tromey@adacore.com> References: <20190227221814.17661-1-tromey@adacore.com> MIME-Version: 1.0 This applies ATTRIBUTE_UNUSED_RESULT to scoped_mmap::release and fixes a couple of spots to comply. 2019-02-27 Tom Tromey * nat/linux-btrace.c (linux_enable_bts, linux_enable_pt): Update. * common/scoped_mmap.h (class scoped_mmap) : Add ATTRIBUTE_UNUSED_RESULT. --- gdb/ChangeLog | 6 ++++++ gdb/common/scoped_mmap.h | 2 +- gdb/nat/linux-btrace.c | 9 +++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gdb/common/scoped_mmap.h b/gdb/common/scoped_mmap.h index 763f40e201c..0b504c96fec 100644 --- a/gdb/common/scoped_mmap.h +++ b/gdb/common/scoped_mmap.h @@ -57,7 +57,7 @@ public: DISABLE_COPY_AND_ASSIGN (scoped_mmap); - void *release () noexcept + ATTRIBUTE_UNUSED_RESULT void *release () noexcept { void *mem = m_mem; m_mem = MAP_FAILED; diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c index b51e70fbaff..ef291ec2310 100644 --- a/gdb/nat/linux-btrace.c +++ b/gdb/nat/linux-btrace.c @@ -544,13 +544,11 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf) bts->bts.size = size; bts->bts.data_head = &header->data_head; - bts->bts.mem = (const uint8_t *) data.get () + data_offset; + bts->bts.mem = (const uint8_t *) data.release () + data_offset; bts->bts.last_head = 0ull; bts->header = header; bts->file = fd.release (); - data.release (); - tinfo->conf.bts.size = (unsigned int) size; return tinfo.release (); } @@ -667,11 +665,10 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf) pt->pt.size = aux.size (); pt->pt.mem = (const uint8_t *) aux.release (); pt->pt.data_head = &header->aux_head; - pt->header = header; + pt->header = (struct perf_event_mmap_page *) data.release (); + gdb_assert (pt->header == header); pt->file = fd.release (); - data.release (); - tinfo->conf.pt.size = (unsigned int) pt->pt.size; return tinfo.release (); }