[Patch, libfortran] Use access(2) instead of stat(2) to test file existence

Janne Blomqvist blomqvist.janne@gmail.com
Mon Aug 2 17:04:00 GMT 2010


Thanks for taking the time to look at the patch.

On Mon, Aug 2, 2010 at 19:29, Richard Henderson <rth@redhat.com> wrote:
> On 07/31/2010 03:41 PM, Janne Blomqvist wrote:
>> +  if ((mode & R_OK) && open (path, O_RDONLY) < 0)
>> +    return -1;
>> +
>> +  if ((mode & W_OK) && open (path, O_WRONLY) < 0)
>> +    return -1;
>
> You're leaking file descriptors here.

Yes, I realized that, however, as this is not actually code that I
wrote as part of this patch I decided to leave it for later. I just
moved the entire function upwards in the file before all users, hence
it showed up in the diff. fallback_access() has been around since
2007, see PR 21185.

In any case, I filed PR 45165 to keep track of this issue.

> Since you're not using [RW]_OK, better to just remove those cases.

It is used by unix.c:inquire_access() and callers of that function.

-- 
Janne Blomqvist



More information about the Gcc-patches mailing list