This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, libgfortran] Make sclose return value match POSIX


Hi,

One of the design goals of the new gfortran low level I/O library was to
match POSIX as far as possible. The attached patch fixes the stream
close operation to always return POSIX compatible values, and fixes the
callers.

After regtesting on i686-pc-linux-gnu, committed r145761 as obvious.



-- 
Janne Blomqvist
2009-04-08  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/open.c (already_open): Test for POSIX close return value.
	* io/unit.c (close_unit_1): Likewise.
	* io/unix.c (raw_close): Return 0 for success for preconnected units.
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index 7caa1c9..e3709f7 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -682,7 +682,7 @@ already_open (st_parameter_open *opp, gfc_unit * u, unit_flags * flags)
 	}
 #endif
 
-      if (sclose (u->s) == FAILURE)
+      if (sclose (u->s) == -1)
 	{
 	  unlock_unit (u);
 	  generate_error (&opp->common, LIBERROR_OS,
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c
index 4c46016..00bea5a 100644
--- a/libgfortran/io/unit.c
+++ b/libgfortran/io/unit.c
@@ -626,7 +626,7 @@ close_unit_1 (gfc_unit *u, int locked)
   if (u->previous_nonadvancing_write)
     finish_last_advance_record (u);
 
-  rc = (u->s == NULL) ? 0 : sclose (u->s) == FAILURE;
+  rc = (u->s == NULL) ? 0 : sclose (u->s) == -1;
 
   u->closed = 1;
   if (!locked)
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 4f8cbb5..2fe73bb 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -349,7 +349,7 @@ raw_close (unix_stream * s)
       && s->fd != STDIN_FILENO)
     retval = close (s->fd);
   else
-    retval = SUCCESS;
+    retval = 0;
   free_mem (s);
   return retval;
 }

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]