diff mbox series

[Fortran] Fix libgfortran/io/close.c for !HAVE_UNLINK_OPEN_FILE

Message ID alpine.LSU.2.21.1809292043530.3785@anthias.pfeifer.com
State New
Headers show
Series [Fortran] Fix libgfortran/io/close.c for !HAVE_UNLINK_OPEN_FILE | expand

Commit Message

Gerald Pfeifer Oct. 2, 2018, 11:08 a.m. UTC
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  <gerald@pfeifer.com>

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

Comments

Janne Blomqvist Oct. 2, 2018, 3:55 p.m. UTC | #1
On Tue, Oct 2, 2018 at 2:08 PM Gerald Pfeifer <gerald@pfeifer.com> wrote:

> 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
>

Ok, thanks!
diff mbox series

Patch

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 }