NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/59210: Use timespeccmp() and st_mtim intead of comparing st_mtime.
>Number: 59210
>Category: bin
>Synopsis: Use timespeccmp() and st_mtim intead of comparing st_mtime.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 25 01:25:00 +0000 2025
>Originator: Collin Funk
>Release: 10.1
>Organization:
GNU
>Environment:
NetBSD 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC 2024 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
On OpenBSD, an autoconf test suite case failed because 'test file1 -ot ft' with /bin/ksh's test builtin does not support nanosecond timestamps.
The patch I sent was pushed on OpenBSD. Here is one for NetBSD which also has the issue.
$ cvs diff -u -N bin/ksh/c_test.c
Index: bin/ksh/c_test.c
===================================================================
RCS file: /cvsroot/src/bin/ksh/c_test.c,v
retrieving revision 1.10
diff -u -r1.10 c_test.c
--- bin/ksh/c_test.c 16 Sep 2021 19:44:01 -0000 1.10
+++ bin/ksh/c_test.c 25 Mar 2025 01:16:51 -0000
@@ -402,7 +402,9 @@
*/
return stat(opnd1, &b1) == 0
&& (((s2 = stat(opnd2, &b2)) == 0
- && b1.st_mtime > b2.st_mtime) || s2 < 0);
+ && timespeccmp(&b1.st_mtim,
+ &b2.st_mtim, >))
+ || s2 != 0);
}
case TO_FILOT: /* -ot */
{
@@ -412,7 +414,9 @@
*/
return stat(opnd2, &b2) == 0
&& (((s1 = stat(opnd1, &b1)) == 0
- && b1.st_mtime < b2.st_mtime) || s1 < 0);
+ && timespeccmp(&b1.st_mtim,
+ &b2.st_mtim, <))
+ || s1 != 0);
}
case TO_FILEQ: /* -ef */
return stat (opnd1, &b1) == 0 && stat (opnd2, &b2) == 0
>How-To-Repeat:
>Fix:
Home |
Main Index |
Thread Index |
Old Index