bug-gnulib
[Top][All Lists]
Advanced

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

utimens: new shadowing warning


From: Jim Meyering
Subject: utimens: new shadowing warning
Date: Thu, 31 Dec 2009 19:10:29 +0100

Hi Eric,

Without this patch, coreutils no longer builds
when configured with --enable-gcc-warnings:

  utimens.c: In function 'lutimens':
  utimens.c:425: error: declaration of 'st' shadows a previous local [-Wshadow]
  utimens.c:404: error: shadowed declaration is here [-Wshadow]

This patch is nearly minimal, but perhaps not ideal.
You might prefer to retain the name "st",
and simply declare each in its own scope,
but that'd be more invasive.

diff --git a/lib/utimens.c b/lib/utimens.c
index cc0d1e8..027b3ec 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -422,7 +422,7 @@ lutimens (char const *file, struct timespec const 
timespec[2])
     {
       int result;
 # if __linux__
-      struct stat st;
+      struct stat stat_buf;
       /* As recently as Linux kernel 2.6.32 (Dec 2009), several file
          systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
          but work if both times are either explicitly specified or
@@ -433,12 +433,12 @@ lutimens (char const *file, struct timespec const 
timespec[2])
          when file system bugs are no longer common.  */
       if (adjustment_needed == 2)
         {
-          if (lstat (file, &st))
+          if (lstat (file, &stat_buf))
             return -1;
           if (ts[0].tv_nsec == UTIME_OMIT)
-            ts[0] = get_stat_atime (&st);
+            ts[0] = get_stat_atime (&stat_buf);
           else if (ts[1].tv_nsec == UTIME_OMIT)
-            ts[1] = get_stat_mtime (&st);
+            ts[1] = get_stat_mtime (&stat_buf);
         }
 # endif /* __linux__ */
       result = utimensat (AT_FDCWD, file, ts, AT_SYMLINK_NOFOLLOW);




reply via email to

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