public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: cast return value of std::unique_ptr::release to void
@ 2023-02-14 19:29 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2023-02-14 19:29 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8eaecfb37c8ece7396303dd3122def526a223d70

commit 8eaecfb37c8ece7396303dd3122def526a223d70
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Mon Feb 13 14:55:13 2023 -0500

    gdb: cast return value of std::unique_ptr::release to void
    
    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
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/value.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gdb/value.c b/gdb/value.c
index 7873aeb9558..6597d0fe4ef 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2347,9 +2347,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;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-14 19:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 19:29 [binutils-gdb] gdb: cast return value of std::unique_ptr::release to void Simon Marchi

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).