Discussion:
[PATCH,Fortran] Fix libgfortran/io/close.c for !HAVE_UNLINK_OPEN_FILE
Gerald Pfeifer
2018-10-02 11:08:42 UTC
Permalink
Revision r215307 | jb | 2014-09-16 23:40:28 +0200 (Di, 16 Sep 2014)

PR libfortran/62768 Handle filenames with embedded null characters.
:

made the changes like the following to libgfortran/io/close.c

#if !HAVE_UNLINK_OPEN_FILE
- path = fc_strdup (u->file, u->file_len);
+ path = strdup (u->filename);
#endif


One of our users now reported this build failure for a system where
(for whatever reason) HAVE_UNLINK_OPEN_FILE is not defined:

.../GCC-HEAD/libgfortran/io/close.c:94:11: error: implicit declaration of function ¡strdup¢
94 | path = strdup (u->filename);
| ^~~~~~


By #undef-ining HAVE_UNLINK_OPEN_FILE beetween the #include "..." and
#include <...> statements in libgfortran/io/close.c I could reproduce
this on FreeBSD 11/i386.

And I could validate the fix below, both with and without that #undef
in place.


Tested on i386-unknown-freebsd11.1.


Okay to commit?

I'd also like to apply this to older release branches (down to GCC 6)
since it is obviously broken and the fix appears straightforward. If
approved, I'm thinking to wait about a week or two before making each
step backwards (from HEAD to 8, 8 to 7, and 7 to 6).

Gerald


2018-10-02 Gerald Pfeifer <***@pfeifer.com>

* io/close.c [!HAVE_UNLINK_OPEN_FILE]: Include <string.h>.

Index: libgfortran/io/close.c
===================================================================
--- libgfortran/io/close.c (revision 264772)
+++ libgfortran/io/close.c (working copy)
@@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respect
#include "unix.h"
#include "async.h"
#include <limits.h>
+#if !HAVE_UNLINK_OPEN_FILE
+#include <string.h>
+#endif

typedef enum
{ CLOSE_DELETE, CLOSE_KEEP, CLOSE_UNSPECIFIED }
Janne Blomqvist
2018-10-02 15:55:33 UTC
Permalink
Post by Gerald Pfeifer
Revision r215307 | jb | 2014-09-16 23:40:28 +0200 (Di, 16 Sep 2014)
PR libfortran/62768 Handle filenames with embedded null characters.
made the changes like the following to libgfortran/io/close.c
#if !HAVE_UNLINK_OPEN_FILE
- path = fc_strdup (u->file, u->file_len);
+ path = strdup (u->filename);
#endif
One of our users now reported this build failure for a system where
.../GCC-HEAD/libgfortran/io/close.c:94:11: error: implicit declaration
of function ‘strdup’
94 | path = strdup (u->filename);
| ^~~~~~
By #undef-ining HAVE_UNLINK_OPEN_FILE beetween the #include "..." and
#include <...> statements in libgfortran/io/close.c I could reproduce
this on FreeBSD 11/i386.
And I could validate the fix below, both with and without that #undef
in place.
Tested on i386-unknown-freebsd11.1.
Okay to commit?
I'd also like to apply this to older release branches (down to GCC 6)
since it is obviously broken and the fix appears straightforward. If
approved, I'm thinking to wait about a week or two before making each
step backwards (from HEAD to 8, 8 to 7, and 7 to 6).
Gerald
Ok, thanks!
--
Janne Blomqvist
Loading...