From: Mike Frysinger <vapier@gentoo.org>
To: bzip2-devel@sourceware.org
Subject: [PATCH] silence unused results warnings from compilers
Date: Sun, 11 Apr 2021 11:07:37 -0400 [thread overview]
Message-ID: <20210411150737.27733-1-vapier@gentoo.org> (raw)
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
reply other threads:[~2021-04-11 15:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210411150737.27733-1-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=bzip2-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).