diff options
author | Arjun Shankar <arjun.is@lostca.se> | 2017-06-07 11:46:24 +0200 |
---|---|---|
committer | Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> | 2018-04-06 15:55:10 -0300 |
commit | 1be1845b280cfadff0cbd09170af554549849ffb (patch) | |
tree | 720e77beac8d1e3d3d26bab07a7631ebacee1e80 /support/xfclose.c | |
parent | 771fb81f98a2be9e96f2a09056617ad93d64959f (diff) | |
download | glibc-1be1845b280cfadff0cbd09170af554549849ffb.tar.gz glibc-1be1845b280cfadff0cbd09170af554549849ffb.tar.xz glibc-1be1845b280cfadff0cbd09170af554549849ffb.zip |
Synchronize support/ infrastructure with master
This commit updates the support/ subdirectory to commit 2714c5f3c95f90977167c1d21326d907fb76b419 on the master branch and modifies Makeconfig, Rules, and extra-lib.mk accordingly. (cherry picked from commit 4c5785aa129a5d195fc1cd5c7fcd6f62c2b0ff0c) Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'support/xfclose.c')
-rw-r--r-- | support/xfclose.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/support/xfclose.c b/support/xfclose.c new file mode 100644 index 0000000000..2737f05044 --- /dev/null +++ b/support/xfclose.c @@ -0,0 +1,33 @@ +/* fclose with error checking. + Copyright (C) 2016-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <support/xstdio.h> + +#include <support/check.h> +#include <stdlib.h> + +void +xfclose (FILE *fp) +{ + if (ferror (fp)) + FAIL_EXIT1 ("stdio stream closed with pending errors"); + if (fflush (fp) != 0) + FAIL_EXIT1 ("fflush: %m"); + if (fclose (fp) != 0) + FAIL_EXIT1 ("fclose: %m"); +} |