From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 5D1823858C27 for ; Mon, 13 Feb 2023 19:55:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D1823858C27 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from localhost.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 13AA11E112; Mon, 13 Feb 2023 14:55:14 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: cast return value of std::unique_ptr::release to void Date: Mon, 13 Feb 2023 14:55:13 -0500 Message-Id: <20230213195513.37532-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1173.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 &&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