This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran] PR 38248 - don't silently fail if unlink/rename fails
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Mon, 24 Nov 2008 17:54:49 +0100
- Subject: [Patch, Fortran] PR 38248 - don't silently fail if unlink/rename fails
The following patch was posted by Jan in the bug report. I think it is OK
and I intent to commit it later today or tomorrow morning.
Tobias
2008-11-24 Jan Kratochvil <jan.kratochvil@redhat.com>
PR fortran/38248
* module.c (gfc_dump_module): Check rename/unlink syscalls errors.
--- gcc/fortran/module.c (revision 142158)
+++ gcc/fortran/module.c (working copy)
@@ -4850,11 +4850,19 @@ gfc_dump_module (const char *name, int d
|| memcmp (md5_old, md5_new, sizeof (md5_old)) != 0)
{
/* Module file have changed, replace the old one. */
- unlink (filename);
- rename (filename_tmp, filename);
+ if (unlink (filename))
+ gfc_fatal_error ("Can't delete module file '%s': %s", filename,
+ strerror (errno));
+ if (rename (filename_tmp, filename))
+ gfc_fatal_error ("Can't rename module file '%s' to '%s': %s",
+ filename_tmp, filename, strerror (errno));
}
else
- unlink (filename_tmp);
+ {
+ if (unlink (filename_tmp))
+ gfc_fatal_error ("Can't delete temporary module file '%s': %s",
+ filename_tmp, strerror (errno));
+ }
}