From: Lennart Poettering Date: Mon, 1 Feb 2021 16:01:14 +0000 (+0100) Subject: copy: simplify futimens() invocation X-Git-Tag: v248-rc1~209^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=150dcaf24875bdbf27d0d85d0358334c97edf69b;p=thirdparty%2Fsystemd.git copy: simplify futimens() invocation --- diff --git a/src/basic/copy.c b/src/basic/copy.c index c2c337c1a1b..aede5be9910 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -593,7 +593,6 @@ static int fd_copy_regular( void *userdata) { _cleanup_close_ int fdf = -1, fdt = -1; - struct timespec ts[2]; int r, q; assert(from); @@ -635,9 +634,7 @@ static int fd_copy_regular( if (fchmod(fdt, st->st_mode & 07777) < 0) r = -errno; - ts[0] = st->st_atim; - ts[1] = st->st_mtim; - (void) futimens(fdt, ts); + (void) futimens(fdt, (struct timespec[]) { st->st_atim, st->st_mtim }); (void) copy_xattr(fdf, fdt); q = close(fdt); @@ -918,11 +915,6 @@ static int fd_copy_directory( } if (created) { - struct timespec ut[2] = { - st->st_atim, - st->st_mtim - }; - if (fchown(fdt, uid_is_valid(override_uid) ? override_uid : st->st_uid, gid_is_valid(override_gid) ? override_gid : st->st_gid) < 0) @@ -932,7 +924,7 @@ static int fd_copy_directory( r = -errno; (void) copy_xattr(dirfd(d), fdt); - (void) futimens(fdt, ut); + (void) futimens(fdt, (struct timespec[]) { st->st_atim, st->st_mtim }); } return r; @@ -1187,7 +1179,6 @@ int copy_file_atomic_full( } int copy_times(int fdf, int fdt, CopyFlags flags) { - struct timespec ut[2]; struct stat st; assert(fdf >= 0); @@ -1196,10 +1187,7 @@ int copy_times(int fdf, int fdt, CopyFlags flags) { if (fstat(fdf, &st) < 0) return -errno; - ut[0] = st.st_atim; - ut[1] = st.st_mtim; - - if (futimens(fdt, ut) < 0) + if (futimens(fdt, (struct timespec[2]) { st.st_atim, st.st_mtim }) < 0) return -errno; if (FLAGS_SET(flags, COPY_CRTIME)) {