Page 1 of 1

[PATCH] Use gettimeofday for NULL times

Posted: Wed Apr 19, 2023 2:47 am
by Extrems

Code: Select all

From 807b2d6cefff45bf708772c611bcf5014db63898 Mon Sep 17 00:00:00 2001
From: Extrems <[email protected]>
Date: Tue, 18 Apr 2023 21:32:35 -0400
Subject: [PATCH 2/2] Use gettimeofday for NULL times

---
 libgloss/libsysbase/utime.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libgloss/libsysbase/utime.c b/libgloss/libsysbase/utime.c
index 462e86520..14b459eef 100644
--- a/libgloss/libsysbase/utime.c
+++ b/libgloss/libsysbase/utime.c
@@ -35,6 +35,10 @@ int utime(const char *filename, const struct utimbuf *times)
                 t[0].tv_usec = 0;
                 t[1].tv_sec  = times->modtime;
                 t[1].tv_usec = 0;
+        } else if (gettimeofday(&t[0], NULL) != -1) {
+                t[1] = t[0];
+        } else {
+                return -1;
         }
 
         return utimes(filename, t);
-- 
2.39.1.windows.1

As per the POSIX specification.

Re: [PATCH] Use gettimeofday for NULL times

Posted: Thu Apr 20, 2023 7:19 pm
by WinterMute
Thanks for this. I applied it to the latest devkitPPC.