From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 7/7] Add ATTRIBUTE_UNUSED_RESULT to ref_ptr::release
Date: Wed, 27 Feb 2019 22:18:00 -0000 [thread overview]
Message-ID: <20190227221814.17661-8-tromey@adacore.com> (raw)
In-Reply-To: <20190227221814.17661-1-tromey@adacore.com>
This applies ATTRIBUTE_UNUSED_RESULT to ref_ptr::release and updates a
few spots to comply. I believe one use in install_default_visualizer
was in error, fixed by this patch.
2019-02-27 Tom Tromey <tromey@adacore.com>
* varobj.c (update_dynamic_varobj_children): Update.
(install_default_visualizer): Use reset, not release.
* value.c (set_internalvar): Update.
* dwarf2loc.c (value_of_dwarf_reg_entry): Update.
* common/gdb_ref_ptr.h (class ref_ptr) <release>: Add
ATTRIBUTE_UNUSED_RESULT.
---
gdb/ChangeLog | 9 +++++++++
gdb/common/gdb_ref_ptr.h | 2 +-
gdb/dwarf2loc.c | 3 +--
gdb/value.c | 10 +++++-----
gdb/varobj.c | 4 ++--
5 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/gdb/common/gdb_ref_ptr.h b/gdb/common/gdb_ref_ptr.h
index b104556cc5f..c31c9a2e58b 100644
--- a/gdb/common/gdb_ref_ptr.h
+++ b/gdb/common/gdb_ref_ptr.h
@@ -135,7 +135,7 @@ class ref_ptr
/* Return this instance's referent, and stop managing this
reference. The caller is now responsible for the ownership of
the reference. */
- T *release ()
+ ATTRIBUTE_UNUSED_RESULT T *release ()
{
T *result = m_obj;
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 9c974a11133..29d289b4d0c 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1472,9 +1472,8 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
target_type, caller_frame,
caller_per_cu);
- release_value (target_val).release ();
val = allocate_computed_value (type, &entry_data_value_funcs,
- target_val /* closure */);
+ release_value (target_val).release ());
/* Copy the referencing pointer to the new computed value. */
memcpy (value_contents_raw (val), value_contents_raw (outer_val),
diff --git a/gdb/value.c b/gdb/value.c
index 95b6a56f32e..50e47a936aa 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2274,20 +2274,20 @@ set_internalvar (struct internalvar *var, struct value *val)
default:
new_kind = INTERNALVAR_VALUE;
- new_data.value = value_copy (val);
- new_data.value->modifiable = 1;
+ struct value *copy = value_copy (val);
+ copy->modifiable = 1;
/* Force the value to be fetched from the target now, to avoid problems
later when this internalvar is referenced and the target is gone or
has changed. */
- if (value_lazy (new_data.value))
- value_fetch_lazy (new_data.value);
+ if (value_lazy (copy))
+ value_fetch_lazy (copy);
/* Release the value from the value chain to prevent it from being
deleted by free_all_values. From here on this function should not
call error () until new_data is installed into the var->u to avoid
leaking memory. */
- release_value (new_data.value).release ();
+ new_data.value = release_value (copy).release ();
/* Internal variables which are created from values with a dynamic
location don't need the location property of the origin anymore.
diff --git a/gdb/varobj.c b/gdb/varobj.c
index b03307068f3..3715bb6a7df 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -760,7 +760,7 @@ update_dynamic_varobj_children (struct varobj *var,
/* Release vitem->value so its lifetime is not bound to the
execution of a command. */
if (item != NULL && item->value != NULL)
- release_value (item->value).release ();
+ item->value = release_value (item->value).release ();
}
if (item == NULL)
@@ -1127,7 +1127,7 @@ install_default_visualizer (struct varobj *var)
}
if (pretty_printer == Py_None)
- pretty_printer.release ();
+ pretty_printer.reset (nullptr);
install_visualizer (var->dynamic, NULL, pretty_printer.release ());
}
--
2.20.1
next prev parent reply other threads:[~2019-02-27 22:18 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 ` Tom Tromey [this message]
2019-02-27 22:18 ` [PATCH 2/7] Add ATTRIBUTE_UNUSED_RESULT to parser_state 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 3/7] Add ATTRIBUTE_UNUSED_RESULT to scoped_fd Tom Tromey
2019-02-27 22:18 ` [PATCH 1/7] Introduce ATTRIBUTE_UNUSED_RESULT and use it Tom Tromey
2019-02-27 22:26 ` [PATCH 0/7] Use warn_unused_result on release methods John Baldwin
2019-02-27 22:28 ` [PATCH 5/7] Add ATTRIBUTE_UNUSED_RESULT to macro_buffer Tom Tromey
2019-02-27 22:28 ` [PATCH 4/7] Add ATTRIBUTE_UNUSED_RESULT to scoped_mmap Tom Tromey
2019-02-28 7:41 ` Metzger, Markus T
2019-02-28 14:59 ` 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-8-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