procps-ng/ps-etime-overflow.patch
Jan Rybar 423c7e57f7 ps: etime overflow reappeared with rewritten library
uptime, w: report user sessions only; upstream backport of 734930e47
Resolves: RHEL-60826
Resolves: RHEL-141839
2026-01-24 20:18:10 +01:00

31 lines
2.4 KiB
Diff

diff --git a/library/pids.c b/library/pids.c
index 41673b5..f9f4f8f 100644
--- a/library/pids.c
+++ b/library/pids.c
@@ -284,13 +284,13 @@ REG_set(TICS_USER, ull_int, utime)
setDECL(TICS_USER_C) { (void)I; R->result.ull_int = P->utime + P->cutime; }
setDECL(TIME_ALL) { R->result.real = ((double)P->utime + P->stime) / I->hertz; }
setDECL(TIME_ALL_C) { R->result.real = ((double)P->utime + P->stime + P->cutime + P->cstime) / I->hertz; }
-setDECL(TIME_ELAPSED) { double t = I->boot_tics - P->start_time; if (t > 0) R->result.real = t / I->hertz; }
+setDECL(TIME_ELAPSED) { double t = (double)I->boot_tics - P->start_time; if (t > 0) R->result.real = t / I->hertz; }
setDECL(TIME_START) { R->result.real = (double)P->start_time / I->hertz; }
REG_set(TTY, s_int, tty)
setDECL(TTY_NAME) { char buf[64]; freNAME(str)(R); dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
setDECL(TTY_NUMBER) { char buf[64]; freNAME(str)(R); dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV|ABBREV_TTY|ABBREV_PTS); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
-setDECL(UTILIZATION) { double t = I->boot_tics - P->start_time; if (t > 0) R->result.real = ((P->utime + P->stime) * 100.0f) / t; }
-setDECL(UTILIZATION_C) { double t = I->boot_tics - P->start_time; if (t > 0) R->result.real = ((P->utime + P->stime + P->cutime + P->cstime) * 100.0f) / t; }
+setDECL(UTILIZATION) { double t = (double)I->boot_tics - P->start_time; if (t > 0) R->result.real = ((P->utime + P->stime) * 100.0f) / t; }
+setDECL(UTILIZATION_C) { double t = (double)I->boot_tics - P->start_time; if (t > 0) R->result.real = ((P->utime + P->stime + P->cutime + P->cstime) * 100.0f) / t; }
REG_set(VM_DATA, ul_int, vm_data)
REG_set(VM_EXE, ul_int, vm_exe)
REG_set(VM_LIB, ul_int, vm_lib)
@@ -304,7 +304,7 @@ REG_set(VM_STACK, ul_int, vm_stack)
REG_set(VM_SWAP, ul_int, vm_swap)
setDECL(VM_USED) { (void)I; R->result.ul_int = P->vm_swap + P->vm_rss; }
REG_set(VSIZE_BYTES, ul_int, vsize)
-setDECL(WCHAN_NAME) { freNAME(str)(R); if (!(R->result.str = strdup(lookup_wchan(P->tid)))) I->seterr = 1;; }
+setDECL(WCHAN_NAME) { freNAME(str)(R); if (!(R->result.str = strdup(lookup_wchan(P->tid)))) I->seterr = 1; }
#undef setDECL
#undef CVT_set