From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 11/11] install_variable cannot fail
Date: Sat, 24 Oct 2020 15:08:56 -0600 [thread overview]
Message-ID: <20201024210856.12021-12-tom@tromey.com> (raw)
In-Reply-To: <20201024210856.12021-1-tom@tromey.com>
I noticed that install_variable will never return false, so this patch
changes the return type to void. I couldn't find a spot in history
where it did return false, maybe it's always been like this.
gdb/ChangeLog
2020-10-24 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_create): Update.
(install_variable): Return void.
---
gdb/ChangeLog | 5 +++++
gdb/varobj.c | 12 +++---------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/gdb/varobj.c b/gdb/varobj.c
index be161eb0208..8254f686653 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -142,7 +142,7 @@ static int delete_variable (struct varobj *, bool);
static void delete_variable_1 (int *, struct varobj *, bool, bool);
-static bool install_variable (struct varobj *);
+static void install_variable (struct varobj *);
static void uninstall_variable (struct varobj *);
@@ -390,11 +390,7 @@ varobj_create (const char *objname,
if ((var != NULL) && (objname != NULL))
{
var->obj_name = objname;
-
- /* If a varobj name is duplicated, the install will fail so
- we must cleanup. */
- if (!install_variable (var.get ()))
- return NULL;
+ install_variable (var.get ());
}
return var.release ();
@@ -1733,7 +1729,7 @@ delete_variable_1 (int *delcountp, struct varobj *var, bool only_children_p,
}
/* Install the given variable VAR with the object name VAR->OBJ_NAME. */
-static bool
+static void
install_variable (struct varobj *var)
{
hashval_t hash = htab_hash_string (var->obj_name.c_str ());
@@ -1749,8 +1745,6 @@ install_variable (struct varobj *var)
/* If root, add varobj to root list. */
if (is_root_p (var))
rootlist.push_front (var->root);
-
- return true; /* OK */
}
/* Uninstall the object VAR. */
--
2.17.2
next prev parent reply other threads:[~2020-10-24 21:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-24 21:08 [PATCH 00/11] Some varobj C++-ification and cleanup Tom Tromey
2020-10-24 21:08 ` [PATCH 01/11] Use htab_t in varobj Tom Tromey
2020-10-24 21:08 ` [PATCH 02/11] Change varobj.c:rootlist to a std::list Tom Tromey
2020-10-24 21:08 ` [PATCH 03/11] Change all_root_varobjs to take a function_view Tom Tromey
2020-10-24 21:08 ` [PATCH 04/11] C++-ify varobj iteration Tom Tromey
2020-10-24 21:08 ` [PATCH 05/11] Change varobj_iter::next to return unique_ptr Tom Tromey
2020-10-24 21:08 ` [PATCH 06/11] Change varobj_dynamic::saved_item to unique_ptr Tom Tromey
2020-10-24 21:08 ` [PATCH 07/11] Change varobj_dynamic::child_iter " Tom Tromey
2020-10-24 21:08 ` [PATCH 08/11] Change varobj_item::value to a value_ref_ptr Tom Tromey
2020-10-24 21:08 ` [PATCH 09/11] Remove varobj_clear_saved_item Tom Tromey
2020-10-24 21:08 ` [PATCH 10/11] Use gdbpy_ref in instantiate_pretty_printer Tom Tromey
2020-10-24 21:08 ` Tom Tromey [this message]
2020-12-11 16:46 ` [PATCH 00/11] Some varobj C++-ification and cleanup 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=20201024210856.12021-12-tom@tromey.com \
--to=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).