bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] lib/rename.c: Conditionally define the out label


From: Ben Walton
Subject: [PATCH] lib/rename.c: Conditionally define the out label
Date: Sun, 1 Jun 2014 09:34:41 +0100

  * Avoid possible compiler warnings/errors by defining the out label
    only when it may be accessed.

Signed-off-by: Ben Walton <address@hidden>
---

Hi All,

When building coreutils 8.22 on Solaris with -Werror=unused-label, the build
fails with:

lib/rename.c: In function 'rpl_rename':
lib/rename.c:465:2: error: label 'out' defined but not used 
[-Werror=unused-label]
  out:
  ^

I think this should make the compiler happier. Feel free to suggest better
solutions though. I'm not sure this is the best way to handle it.

 lib/rename.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/rename.c b/lib/rename.c
index 2116028..9c507c2 100644
--- a/lib/rename.c
+++ b/lib/rename.c
@@ -462,7 +462,14 @@ rpl_rename (char const *src, char const *dst)
 
   ret_val = rename (src_temp, dst_temp);
   rename_errno = errno;
+
+# if (RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG        \
+      || RENAME_HARD_LINK_BUG)
+  /* Avoid compiler warnings about unused labels. Only
+     create this label if it will be used. */
  out:
+# endif
+
   if (src_temp != src)
     free (src_temp);
   if (dst_temp != dst)
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]