From 0ecf0981e55ef30db839cd92b36d21829c42502b Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 24 Mar 2025 20:15:08 +0000 Subject: [PATCH] Use timespeccmp() and st_mtim intead of comparing st_mtime. Fixes comparison of files with modification times that differ by less than a second. From Collin Funk. --- bin/test/test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/test/test.c b/bin/test/test.c index 21c27642455..974f8a86272 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test.c,v 1.22 2024/08/15 06:27:24 guenther Exp $ */ +/* $OpenBSD: test.c,v 1.23 2025/03/24 20:15:08 millert Exp $ */ /* $NetBSD: test.c,v 1.15 1995/03/21 07:04:06 cgd Exp $ */ /* @@ -546,7 +546,7 @@ newerf(const char *f1, const char *f2) return (stat(f1, &b1) == 0 && stat(f2, &b2) == 0 && - b1.st_mtime > b2.st_mtime); + timespeccmp(&b1.st_mtim, &b2.st_mtim, >)); } static int @@ -556,7 +556,7 @@ olderf(const char *f1, const char *f2) return (stat(f1, &b1) == 0 && stat(f2, &b2) == 0 && - b1.st_mtime < b2.st_mtime); + timespeccmp(&b1.st_mtim, &b2.st_mtim, <)); } static int