This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] Don't call stat before fopen


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.


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");
 }


-- 
Janne Blomqvist


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]