git: ee2e36686e84 - main - linprocfs: Really fix time_t type issue

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 12 May 2024 04:57:19 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=ee2e36686e846d412deac23344185f4b8a8c0285

commit ee2e36686e846d412deac23344185f4b8a8c0285
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-05-12 04:53:15 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-12 04:53:15 +0000

    linprocfs: Really fix time_t type issue
    
    The cast to (long) is wrong on all the other 32-bit platforms. (long
    long) is the correct type on all platforms. Also, use a z modifier for
    size_t which also fails on 32-bit platforms.
    
    Fixes: 02f481a30b82
    Sponsored by: Netflix
---
 sys/compat/linprocfs/linprocfs.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index aa5af0b3c1c1..dd04adc054db 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -2133,7 +2133,7 @@ again:
 	for (id = 0; id < msgmni; id++)
 		if (msqids[id].u.msg_qbytes != 0)
 			sbuf_printf(sb,
-			    "%10d %10lu  %4o  %10lu %10lu %5u %5u %5u %5u %5u %5u %10ld %10ld %10ld\n",
+			    "%10d %10lu  %4o  %10lu %10lu %5u %5u %5u %5u %5u %5u %10lld %10lld %10lld\n",
 			    (int) msqids[id].u.msg_perm.key,
 			    IXSEQ_TO_IPCID(id, msqids[id].u.msg_perm),
 			    msqids[id].u.msg_perm.mode,
@@ -2145,9 +2145,9 @@ again:
 			    msqids[id].u.msg_perm.gid,
 			    msqids[id].u.msg_perm.cuid,
 			    msqids[id].u.msg_perm.cgid,
-			    (long)msqids[id].u.msg_stime,
-			    (long)msqids[id].u.msg_rtime,
-			    (long)msqids[id].u.msg_ctime);
+			    (long long)msqids[id].u.msg_stime,
+			    (long long)msqids[id].u.msg_rtime,
+			    (long long)msqids[id].u.msg_ctime);
 
 	free(msqids, M_TEMP);
 	return (0);
@@ -2190,7 +2190,7 @@ again:
 	for (id = 0; id < semmni; id++)
 		if ((semids[id].u.sem_perm.mode & SEM_ALLOC) != 0)
 			sbuf_printf(sb,
-			    "%10d %10lu  %4o %10u %5u %5u %5u %5u %10ld %10ld\n",
+			    "%10d %10lu  %4o %10u %5u %5u %5u %5u %10lld %10lld\n",
 			    (int) semids[id].u.sem_perm.key,
 			    IXSEQ_TO_IPCID(id, semids[id].u.sem_perm),
 			    semids[id].u.sem_perm.mode,
@@ -2199,8 +2199,8 @@ again:
 			    semids[id].u.sem_perm.gid,
 			    semids[id].u.sem_perm.cuid,
 			    semids[id].u.sem_perm.cgid,
-			    (long)semids[id].u.sem_otime,
-			    (long)semids[id].u.sem_ctime);
+			    (long long)semids[id].u.sem_otime,
+			    (long long)semids[id].u.sem_ctime);
 
 	free(semids, M_TEMP);
 	return (0);
@@ -2244,7 +2244,7 @@ again:
 	for (id = 0; id < shmmni; id++)
 		if ((shmids[id].u.shm_perm.mode & SHMSEG_ALLOCATED) != 0)
 			sbuf_printf(sb,
-			    "%10d %10lu  %4o %21lu %5u %5u  %5u %5u %5u %5u %5u %10ld %10ld %10ld %21d %21d\n",
+			    "%10d %10lu  %4o %21zu %5u %5u  %5u %5u %5u %5u %5u %10lld %10lld %10lld %21d %21d\n",
 			    (int) shmids[id].u.shm_perm.key,
 			    IXSEQ_TO_IPCID(id, shmids[id].u.shm_perm),
 			    shmids[id].u.shm_perm.mode,
@@ -2256,9 +2256,9 @@ again:
 			    shmids[id].u.shm_perm.gid,
 			    shmids[id].u.shm_perm.cuid,
 			    shmids[id].u.shm_perm.cgid,
-			    (long)shmids[id].u.shm_atime,
-			    (long)shmids[id].u.shm_dtime,
-			    (long)shmids[id].u.shm_ctime,
+			    (long long)shmids[id].u.shm_atime,
+			    (long long)shmids[id].u.shm_dtime,
+			    (long long)shmids[id].u.shm_ctime,
 			    0, 0);	/* XXX rss & swp are not supported */
 
 	free(shmids, M_TEMP);