This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libfortran] Use access(2) instead of stat(2) to test file existence
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 2 Aug 2010 20:03:54 +0300
- Subject: Re: [Patch, libfortran] Use access(2) instead of stat(2) to test file existence
- References: <AANLkTikbqPA0r_0j2O1QRFp71n-a_ubquvX5dfjtKPnm@mail.gmail.com> <4C56F256.8010902@redhat.com>
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