util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH] closestream: remove dummy function __fpending()
Date: Sat, 10 Mar 2018 21:20:24 +0000	[thread overview]
Message-ID: <20180310212024.5126-1-kerolasa@iki.fi> (raw)

Exclude __fpending() from build when function is not available.  This is
more obvious than adding a dummy function and expecting compiler to
eliminate it as dead code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 include/closestream.h | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/closestream.h b/include/closestream.h
index 2dfe11360..b3b257c94 100644
--- a/include/closestream.h
+++ b/include/closestream.h
@@ -14,22 +14,20 @@
 # define CLOSE_EXIT_CODE EXIT_FAILURE
 #endif
 
-#ifndef HAVE___FPENDING
-static inline int
-__fpending(FILE *stream __attribute__((__unused__)))
-{
-	return 0;
-}
-#endif
-
 static inline int
 close_stream(FILE * stream)
 {
+#ifdef HAVE___FPENDING
 	const int some_pending = (__fpending(stream) != 0);
+#endif
 	const int prev_fail = (ferror(stream) != 0);
 	const int fclose_fail = (fclose(stream) != 0);
 
-	if (prev_fail || (fclose_fail && (some_pending || errno != EBADF))) {
+	if (prev_fail || (fclose_fail && (
+#ifdef HAVE___FPENDING
+					  some_pending ||
+#endif
+					  errno != EBADF))) {
 		if (!fclose_fail && !(errno == EPIPE))
 			errno = 0;
 		return EOF;
-- 
2.16.2


             reply	other threads:[~2018-03-10 21:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-10 21:20 Sami Kerola [this message]
2018-03-27 11:53 ` [PATCH] closestream: remove dummy function __fpending() Karel Zak

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=20180310212024.5126-1-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.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 NNTP newsgroup(s).