File: Use-t64-for-unsigned-utmp.patch

package info (click to toggle)
acct 6.6.4-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,488 kB
  • sloc: ansic: 16,081; sh: 11,379; cpp: 290; makefile: 153
file content (32 lines) | stat: -rw-r--r-- 941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Author: Andrew Bower <andrew@bower.uk>
Last-Update: 2025-09-03
Description: y2038: use t64 for arithmetic on unsigned utmp tv_sec
 Eliminates -Wformat-truncation evident with gcc-15

---
 last.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/last.c b/last.c
index 8dd1daa..be181af 100644
--- a/last.c
+++ b/last.c
@@ -675,7 +675,8 @@ void print_record(struct utmp *login, time_t logout_time,
       char temp_str[15];
 #endif
       int days, hours, minutes, seconds;
-      int diff, use_last_event = 0;
+      time_t diff;
+      int use_last_event = 0;
 
       if (logout_time == 0)
         {
@@ -683,7 +684,7 @@ void print_record(struct utmp *login, time_t logout_time,
           use_last_event = 1;
         }
 
-      diff = (int) logout_time - login->ut_time;
+      diff = logout_time - login->ut_time;
       days = (int) (diff / 86400);
       diff -= 86400 * days;
       hours = (int) (diff / 3600);