]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
closestream: remove dummy function __fpending()
authorSami Kerola <kerolasa@iki.fi>
Sat, 10 Mar 2018 21:20:24 +0000 (21:20 +0000)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Mar 2018 11:51:02 +0000 (13:51 +0200)
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

index 2dfe113603bd2806677dcdb775c7e2b16b328b87..b3b257c94abee8f0f0f10649ecc46b7484bd17b3 100644 (file)
 # 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;