From: Collin Funk Date: Thu, 9 Apr 2026 05:34:13 +0000 (-0700) Subject: maint: touch: prefer timespec_cmp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd5d98e8a7b05ef5e71e748942877d636f0a1f2b;p=thirdparty%2Fcoreutils.git maint: touch: prefer timespec_cmp * src/touch.c (main): Use timespec_cmp instead of comparing each member of the timespec. --- diff --git a/src/touch.c b/src/touch.c index 3d369ee427..ad1ea5e0ef 100644 --- a/src/touch.c +++ b/src/touch.c @@ -385,8 +385,7 @@ main (int argc, char **argv) it were absent; this lets "touch" succeed more often in the presence of restrictive permissions. */ if (change_times == (CH_ATIME | CH_MTIME) - && newtime[0].tv_sec == now.tv_sec - && newtime[0].tv_nsec == now.tv_nsec) + && timespec_cmp (newtime[0], now) == 0) { /* Check that it really was "-d now", and not a timestamp that just happens to be the current time. */ @@ -394,8 +393,7 @@ main (int argc, char **argv) notnow.tv_sec = now.tv_sec ^ 1; notnow.tv_nsec = now.tv_nsec; notnow1 = date_relative (flex_date, notnow); - if (notnow1.tv_sec == notnow.tv_sec - && notnow1.tv_nsec == notnow.tv_nsec) + if (timespec_cmp (notnow1, notnow) == 0) date_set = false; } }