From e63ee1f16c6b8633ed7385d1e7f2531b5dfda8f5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 30 Oct 2002 06:19:00 +0000 Subject: [PATCH] (xfclose): Return void, not int, since it always returned zero. Report I/O error if ferror indicates one. --- src/files.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/files.c b/src/files.c index 92573585..da4c36b1 100644 --- a/src/files.c +++ b/src/files.c @@ -120,19 +120,17 @@ xfopen (const char *name, const char *mode) | Try to close file PTR, and print an error message if fails. | `-------------------------------------------------------------*/ -int +void xfclose (FILE *ptr) { - int result; - if (ptr == NULL) - return 0; + return; - result = fclose (ptr); - if (result == EOF) - error (EXIT_FAILURE, errno, _("cannot close file")); + if (ferror (ptr)) + error (EXIT_FAILURE, 0, _("I/O error")); - return result; + if (fclose (ptr) != 0) + error (EXIT_FAILURE, errno, _("cannot close file")); } -- 2.47.2