From ba94ef5b1b58fad68d0c793bcd8b3bf89fb2dc53 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 12 May 2001 08:04:44 +0000 Subject: (mode_changed, change_file_mode): There's no need to invoke both lstat and stat here, so call just one of the two functions. --- src/chmod.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/chmod.c b/src/chmod.c index dd3c42dcd..7605ca114 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -100,23 +100,13 @@ mode_changed (const char *file, mode_t old_mode) { struct stat new_stats; - if (lstat (file, &new_stats)) + if (stat (file, &new_stats)) { if (force_silent == 0) error (0, errno, _("getting new attributes of %s"), quote (file)); return 0; } -#ifdef S_ISLNK - if (S_ISLNK (new_stats.st_mode) - && stat (file, &new_stats)) - { - if (force_silent == 0) - error (0, errno, _("getting new attributes of %s"), quote (file)); - return 0; - } -#endif - return old_mode != new_stats.st_mode; } @@ -165,25 +155,16 @@ change_file_mode (const char *file, const struct mode_change *changes, int fail; int saved_errno; - if (lstat (file, &file_stats)) + if (deref_symlink ? stat (file, &file_stats) : lstat (file, &file_stats)) { if (force_silent == 0) error (0, errno, _("getting attributes of %s"), quote (file)); return 1; } + #ifdef S_ISLNK if (S_ISLNK (file_stats.st_mode)) - { - if (! deref_symlink) - return 0; - else - if (stat (file, &file_stats)) - { - if (force_silent == 0) - error (0, errno, _("getting attributes of %s"), quote (file)); - return 1; - } - } + return 0; #endif newmode = mode_adjust (file_stats.st_mode, changes); -- cgit v1.2.3-70-g09d2