From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH] gdb: cast return value of std::unique_ptr::release to void
Date: Mon, 13 Feb 2023 14:55:13 -0500 [thread overview]
Message-ID: <20230213195513.37532-1-simon.marchi@efficios.com> (raw)
My editor shows warnings like:
value.c:2784: warning: The value returned by this function should be used
value.c:2784: note: cast the expression to void to silence this warning [bugprone-unused-return-value]
These warnings come from clangd, so ultimately from one of the clang
static analyzers (probably clang-tidy).
Silence these warnings by casting to void. Add a comment to explain
why this unusual thing is done.
Change-Id: I58323959c0baf9f1b20a8d596e4c58dc77c6809a
---
gdb/value.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gdb/value.c b/gdb/value.c
index 4be408e68702..a325b5ce5523 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2781,9 +2781,12 @@ add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
{
struct cmd_list_element *cmd
= do_add_internal_function (name.get (), doc.get (), handler, cookie);
- doc.release ();
+
+ /* Manually transfer the ownership of the doc and name strings to CMD by
+ setting the appropriate flags. */
+ (void) doc.release ();
cmd->doc_allocated = 1;
- name.release ();
+ (void) name.release ();
cmd->name_allocated = 1;
}
--
2.39.1
next reply other threads:[~2023-02-13 19:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 19:55 Simon Marchi [this message]
2023-02-14 0:13 ` Tom Tromey
2023-02-14 19:29 ` Simon Marchi
2023-02-15 17:04 ` 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=20230213195513.37532-1-simon.marchi@efficios.com \
--to=simon.marchi@efficios.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).