* [PATCH] closestream: remove dummy function __fpending()
@ 2018-03-10 21:20 Sami Kerola
2018-03-27 11:53 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Sami Kerola @ 2018-03-10 21:20 UTC (permalink / raw)
To: util-linux; +Cc: Sami Kerola
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] closestream: remove dummy function __fpending()
2018-03-10 21:20 [PATCH] closestream: remove dummy function __fpending() Sami Kerola
@ 2018-03-27 11:53 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2018-03-27 11:53 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Sat, Mar 10, 2018 at 09:20:24PM +0000, Sami Kerola wrote:
> include/closestream.h | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-27 11:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-10 21:20 [PATCH] closestream: remove dummy function __fpending() Sami Kerola
2018-03-27 11:53 ` Karel Zak
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).