Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 4/7] Add ATTRIBUTE_UNUSED_RESULT to scoped_mmap
Date: Wed, 27 Feb 2019 22:28:00 -0000	[thread overview]
Message-ID: <20190227221814.17661-5-tromey@adacore.com> (raw)
In-Reply-To: <20190227221814.17661-1-tromey@adacore.com>

This applies ATTRIBUTE_UNUSED_RESULT to scoped_mmap::release and fixes
a couple of spots to comply.

2019-02-27  Tom Tromey  <tromey@adacore.com>

	* nat/linux-btrace.c (linux_enable_bts, linux_enable_pt): Update.
	* common/scoped_mmap.h (class scoped_mmap) <release>: 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 ();
 }
-- 
2.20.1


  parent reply	other threads:[~2019-02-27 22:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27 22:18 [PATCH 0/7] Use warn_unused_result on release methods Tom Tromey
2019-02-27 22:18 ` [PATCH 6/7] Add ATTRIBUTE_UNUSED_RESULT to scoped_remote_fd::release Tom Tromey
2019-02-27 22:18 ` [PATCH 2/7] Add ATTRIBUTE_UNUSED_RESULT to parser_state Tom Tromey
2019-02-27 22:18 ` [PATCH 1/7] Introduce ATTRIBUTE_UNUSED_RESULT and use it Tom Tromey
2019-02-27 22:18 ` [PATCH 3/7] Add ATTRIBUTE_UNUSED_RESULT to scoped_fd Tom Tromey
2019-02-27 22:18 ` [PATCH 7/7] Add ATTRIBUTE_UNUSED_RESULT to ref_ptr::release Tom Tromey
2019-02-27 22:26 ` [PATCH 0/7] Use warn_unused_result on release methods John Baldwin
2019-02-27 22:28 ` Tom Tromey [this message]
2019-02-28  7:41   ` [PATCH 4/7] Add ATTRIBUTE_UNUSED_RESULT to scoped_mmap Metzger, Markus T
2019-02-28 14:59     ` Tom Tromey
2019-02-27 22:28 ` [PATCH 5/7] Add ATTRIBUTE_UNUSED_RESULT to macro_buffer Tom Tromey
2019-03-05 15:46 ` [PATCH 0/7] Use warn_unused_result on release methods Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190227221814.17661-5-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox