]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp,mv,install: minor copy_internal refactoring
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Sep 2023 16:10:21 +0000 (09:10 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Sep 2023 23:25:39 +0000 (16:25 -0700)
* src/copy.c (copy_internal): Redo to avoid need for calculating
fstatat_flags when not needed.  This is for clarity, not speed.

src/copy.c

index 18945a494b716f3ecedc4589cd5dcbf482eea692..75cd7f081bfd3fb751416ff75679c0e131d2f3b6 100644 (file)
@@ -2309,11 +2309,10 @@ copy_internal (char const *src_name, char const *dst_name,
                || x->move_mode || x->symbolic_link || x->hard_link
                || x->backup_type != no_backups
                || x->unlink_dest_before_opening);
-          int fstatat_flags = use_lstat ? AT_SYMLINK_NOFOLLOW : 0;
           if (!use_lstat && nonexistent_dst < 0)
             new_dst = true;
-          else if (follow_fstatat (dst_dirfd, drelname, &dst_sb, fstatat_flags)
-                   == 0)
+          else if (0 <= follow_fstatat (dst_dirfd, drelname, &dst_sb,
+                                        use_lstat ? AT_SYMLINK_NOFOLLOW : 0))
             {
               have_dst_lstat = use_lstat;
               rename_errno = EEXIST;