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: Richard Henderson <rth at redhat dot com>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 02 Aug 2010 09:29:10 -0700
- Subject: Re: [Patch, libfortran] Use access(2) instead of stat(2) to test file existence
- References: <AANLkTikbqPA0r_0j2O1QRFp71n-a_ubquvX5dfjtKPnm@mail.gmail.com>
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.
Since you're not using [RW]_OK, better to just remove those cases.
r~