From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 1C3F2385840D; Tue, 14 Feb 2023 19:29:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C3F2385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676402977; bh=d5HXKNHTmvE/VYZsvRg90uY0NpoUawKtyqBg+R38N8g=; h=From:To:Subject:Date:From; b=LtYOB3v2zBeehyMpUHwCpm04Ud+jUVd7N0sNXqw6q9OqK03Wqj146vD0oPt41cTLY Bn7QUp5k14pzYrPlpmZsjCOzMbF24Fq5QHaLYVbPuf15wgpU1juJRwU9Ii7M2y46WJ wWFeAkf0zQ09pDwLDzwrNj3hFggxBBpcivQLpj28= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: cast return value of std::unique_ptr::release to void X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 92a2cc556c702154fcbc69f7def2a023185f25dd X-Git-Newrev: 8eaecfb37c8ece7396303dd3122def526a223d70 Message-Id: <20230214192937.1C3F2385840D@sourceware.org> Date: Tue, 14 Feb 2023 19:29:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D8eaecfb37c8e= ce7396303dd3122def526a223d70 commit 8eaecfb37c8ece7396303dd3122def526a223d70 Author: Simon Marchi Date: Mon Feb 13 14:55:13 2023 -0500 gdb: cast return value of std::unique_ptr::release to void =20 My editor shows warnings like: =20 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 wa= rning [bugprone-unused-return-value] =20 These warnings come from clangd, so ultimately from one of the clang static analyzers (probably clang-tidy). =20 Silence these warnings by casting to void. Add a comment to explain why this unusual thing is done. =20 Change-Id: I58323959c0baf9f1b20a8d596e4c58dc77c6809a Approved-By: Tom Tromey 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= &&name, { struct cmd_list_element *cmd =3D 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 =3D 1; - name.release (); + (void) name.release (); cmd->name_allocated =3D 1; }