Skip to content

Commit 8eaecfb

Browse files
committed
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 <[email protected]>
1 parent 92a2cc5 commit 8eaecfb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gdb/value.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,9 +2347,12 @@ add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
23472347
{
23482348
struct cmd_list_element *cmd
23492349
= do_add_internal_function (name.get (), doc.get (), handler, cookie);
2350-
doc.release ();
2350+
2351+
/* Manually transfer the ownership of the doc and name strings to CMD by
2352+
setting the appropriate flags. */
2353+
(void) doc.release ();
23512354
cmd->doc_allocated = 1;
2352-
name.release ();
2355+
(void) name.release ();
23532356
cmd->name_allocated = 1;
23542357
}
23552358

0 commit comments

Comments
 (0)