* lib/renameat2.c (renameat2): Set ret_val properly on old Solaris.
Add goto to use a label, to silence picky compilers.
---
 ChangeLog       | 4 ++++
 lib/renameat2.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 5eee4ae..ce7c46b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-07-30  Paul Eggert  <egg...@cs.ucla.edu>
 
+       renameat2: port better to older Solaris
+       * lib/renameat2.c (renameat2): Set ret_val properly on old Solaris.
+       Add goto to use a label, to silence picky compilers.
+
        fts-tests: port to gcc -Wwrite-strings
        * tests/test-fts.c (base, base_d): New static vars.
        (argv, remove_tree, main): Use them.
diff --git a/lib/renameat2.c b/lib/renameat2.c
index e223653..4f9e3d1 100644
--- a/lib/renameat2.c
+++ b/lib/renameat2.c
@@ -147,6 +147,7 @@ renameat2 (int fd1, char const *src, int fd2, char const 
*dst,
   /* See the lengthy comment in rename.c why Solaris 9 is forced to
      GNU behavior, while Solaris 10 is left with POSIX behavior,
      regarding symlinks with trailing slash.  */
+  ret_val = -1;
   if (src_slash)
     {
       src_temp = strdup (src);
@@ -194,6 +195,7 @@ renameat2 (int fd1, char const *src, int fd2, char const 
*dst,
 
   ret_val = renameat (fd1, src_temp, fd2, dst_temp);
   rename_errno = errno;
+  goto out;
  out:
   if (src_temp != src)
     free (src_temp);
-- 
2.7.4


Reply via email to