[PATCH] Use gettimeofday for NULL times

Got something cool to help make the toolchains better? Post it here.
Post Reply
Extrems
Posts: 3
Joined: Sat Dec 26, 2020 11:26 pm
Location: Québec, Canada
Contact:

[PATCH] Use gettimeofday for NULL times

Post by Extrems » Wed Apr 19, 2023 2:47 am

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.

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: [PATCH] Use gettimeofday for NULL times

Post by WinterMute » Thu Apr 20, 2023 7:19 pm

Thanks for this. I applied it to the latest devkitPPC.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests