libgfortran patch for fortran PR 18653
Richard Henderson
rth@redhat.com
Wed Dec 1 19:57:00 GMT 2004
On Wed, Dec 01, 2004 at 10:43:10AM -0800, Steve Ellcey wrote:
> ! if (file_exists() && file_is_readable() && !file_is_writable())
> ! flags->action = ACTION_READ;
> ! else if (file_exists() && file_is_writable() && !file_is_readable())
> ! flags->action = ACTION_WRITE;
> ! else
> ! flags->action = ACTION_READWRITE;
It would seem a shame to use 6 system calls to figure out one piece
of information.
Additionally, there's a classical race condition here between the
access and the open system call. Ideally, you'd attempt the open
with the most permissive options (readwrite), and then fall back
to read or write if that fails. But in all cases you use the error
from the open system call as the test, rather than a prior access
system call.
r~
More information about the Fortran
mailing list