public inbox for bzip2-devel@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] silence unused results warnings from compilers
@ 2021-04-11 15:07 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2021-04-11 15:07 UTC (permalink / raw)
  To: bzip2-devel

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-11 15:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-11 15:07 [PATCH] silence unused results warnings from compilers Mike Frysinger

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).