public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran, committed] Use ISO C remove() instead of unlink()
@ 2014-08-29 21:21 Janne Blomqvist
  0 siblings, 0 replies; only message in thread
From: Janne Blomqvist @ 2014-08-29 21:21 UTC (permalink / raw)
  To: Fortran List, GCC Patches

Hi,

when removing a file we can instead use the remove() function
specified in ISO C instead of unlink(), as found in POSIX, Windows and
probably other systems as well. Thus giving us a bit better guarantee
about the provided semantics, which header file it's found in etc.

Committed to trunk as obvious.

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog       (revision 214743)
+++ gcc/fortran/ChangeLog       (working copy)
@@ -1,3 +1,8 @@
+2014-08-30  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       * module.c (gfc_dump_module): Use ISO C remove() instead of POSIX
+       unlink().
+
 2014-08-29  Jeffrey Armstrong  <jeffrey.armstrong@approximatrix.com>

        PR fortran/62215
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c        (revision 214743)
+++ gcc/fortran/module.c        (working copy)
@@ -6000,7 +6000,7 @@ gfc_dump_module (const char *name, int d
      module file, even if it was already there.  */
   if (!dump_flag)
     {
-      unlink (filename);
+      remove (filename);
       return;
     }

@@ -6040,7 +6040,7 @@ gfc_dump_module (const char *name, int d
       || crc_old != crc)
     {
       /* Module file have changed, replace the old one.  */
-      if (unlink (filename) && errno != ENOENT)
+      if (remove (filename) && errno != ENOENT)
        gfc_fatal_error ("Can't delete module file '%s': %s", filename,
                         xstrerror (errno));
       if (rename (filename_tmp, filename))
@@ -6049,7 +6049,7 @@ gfc_dump_module (const char *name, int d
     }
   else
     {
-      if (unlink (filename_tmp))
+      if (remove (filename_tmp))
        gfc_fatal_error ("Can't delete temporary module file '%s': %s",
                         filename_tmp, xstrerror (errno));
     }

-- 
Janne Blomqvist

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-29 21:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-29 21:21 [Patch, fortran, committed] Use ISO C remove() instead of unlink() Janne Blomqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).