diff options
author | Sami Kerola | 2018-03-10 22:20:24 +0100 |
---|---|---|
committer | Karel Zak | 2018-03-27 13:51:02 +0200 |
commit | b211467f77892f418da091278e47b9fe1baabe4b (patch) | |
tree | f9ef105e93c9641e09c2141115e1387cbd489307 /include/closestream.h | |
parent | docs: add cal(1) TODO items (diff) | |
download | kernel-qcow2-util-linux-b211467f77892f418da091278e47b9fe1baabe4b.tar.gz kernel-qcow2-util-linux-b211467f77892f418da091278e47b9fe1baabe4b.tar.xz kernel-qcow2-util-linux-b211467f77892f418da091278e47b9fe1baabe4b.zip |
closestream: remove dummy function __fpending()
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>
Diffstat (limited to 'include/closestream.h')
-rw-r--r-- | include/closestream.h | 16 |
1 files 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; |