diff mbox

[libgfortran] Fix PR59108 ACTION='READ' is using O_CREAT

Message ID 528671E6.7010802@charter.net
State New
Headers show

Commit Message

Jerry DeLisle Nov. 15, 2013, 7:11 p.m. UTC
The attached patch sets the create flag for the case where action is specified
as read only.

I have confirmed that the PR test case now only produces:

open("wombat", O_RDONLY)                = 3
open("numbat", O_RDONLY)                = 4
open("dingbat", O_RDONLY)               = 5
+++ exited with 0 +++

I can not think of a test case for this.

Regression tested on x86-64 Linux.

OK for trunk?

Regards,

Jerry

2013-11-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/59108
	* io/unix.c (regular_file): If the ACTION is read only set
	create flag to zero.

Comments

Tobias Burnus Nov. 16, 2013, 7:35 a.m. UTC | #1
Jerry DeLisle wrote:
> The attached patch sets the create flag for the case where action is specified
> as read only.

> Regression tested on x86-64 Linux.
> OK for trunk?

OK. Thanks for the patch!

Tobias

> 2013-11-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
>
> 	PR fortran/59108
> 	* io/unix.c (regular_file): If the ACTION is read only set
> 	create flag to zero.
>
diff mbox

Patch

Index: unix.c
===================================================================
--- unix.c	(revision 204848)
+++ unix.c	(working copy)
@@ -1329,6 +1329,10 @@  regular_file (st_parameter_open *opp, unit_flags *
       break;
 
     case STATUS_UNKNOWN:
+      crflag = 0;
+      if (flags->action == ACTION_READ)
+	break;
+      /* Fall through.  */
     case STATUS_SCRATCH:
       crflag = O_CREAT;
       break;