From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id A774939CBC11 for ; Sun, 11 Apr 2021 15:07:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A774939CBC11 Received: from vapier.lan (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 8CA2F335CEA for ; Sun, 11 Apr 2021 15:07:40 +0000 (UTC) From: Mike Frysinger To: bzip2-devel@sourceware.org Subject: [PATCH] silence unused results warnings from compilers Date: Sun, 11 Apr 2021 11:07:37 -0400 Message-Id: <20210411150737.27733-1-vapier@gentoo.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: bzip2-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bzip2-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 15:07:42 -0000 Newer C libraries mark these funcs with warn_unused_result, and newer compilers use that to emit warnings. The classic (void) cast is not sufficient either. Put them into an if() check with an empty body. --- bzip2.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bzip2.c b/bzip2.c index d1f2fa85357c..0f3adfbc3428 100644 --- a/bzip2.c +++ b/bzip2.c @@ -854,6 +854,8 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n ) " system, please try and read it before mailing me. If you don't\n" " have the manual or can't be bothered to read it, mail me anyway.\n" "\n"; + /* Ignore any errors from write. Not much we can do here. */ +#define write(...) if (write(__VA_ARGS__)) {} write ( STDERR_FILENO, "\n", 1 ); write ( STDERR_FILENO, progName, strlen ( progName ) ); write ( STDERR_FILENO, msg, strlen ( msg ) ); @@ -866,6 +868,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n ) write ( STDERR_FILENO, msg, strlen (msg) ); write ( STDERR_FILENO, outName, strlen (outName) ); write ( STDERR_FILENO, "\n", 1 ); +#undef write /* Don't call cleanupAndFail. If we ended up here something went terribly wrong. Trying to clean up might fail spectacularly. */ @@ -1078,10 +1081,11 @@ void applySavedFileAttrToOutputFile ( IntNative fd ) retVal = fchmod ( fd, fileMetaInfo.st_mode ); ERROR_IF_NOT_ZERO ( retVal ); - (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid ); - /* chown() will in many cases return with EPERM, which can - be safely ignored. - */ + if (fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid )) { + /* chown() will in many cases return with EPERM, which can + be safely ignored. + */ + } # endif } -- 2.30.2