diff mbox

[fortran] Don't call stat before fopen

Message ID CAO9iq9HFwwT-Ui0CrH8054pAxq8bF8EETRrAN5=z4mar3X0-cg@mail.gmail.com
State New
Headers show

Commit Message

Janne Blomqvist Dec. 1, 2011, 8:59 a.m. UTC
Hi,

there's no need to stat() the filename before we fopen() it in
gfc_open_file(). If the file doesn't exist, fopen() will return NULL
anyway, and if the user really wants to read source or module data
from a special file, so be it.

Committed to trunk as obvious.

2011-12-01  Janne Blomqvist  <jb@gcc.gnu.org>

	* misc.c (gfc_open_file): Don't call stat.
diff mbox

Patch

Index: misc.c
===================================================================
--- misc.c      (revision 181874)
+++ misc.c      (working copy)
@@ -58,17 +58,9 @@  gfc_clear_ts (gfc_typespec *ts)
 FILE *
 gfc_open_file (const char *name)
 {
-  struct stat statbuf;
-
   if (!*name)
     return stdin;

-  if (stat (name, &statbuf) < 0)
-    return NULL;
-
-  if (!S_ISREG (statbuf.st_mode))
-    return NULL;
-
   return fopen (name, "r");
 }