On Thu, 15 Nov 2007, Alexandre Julliard wrote:
CpuUsage and CpuKernelUsage are of type ULONG, so it does not make sense checking whether they are less than 0.
The checks should most likely done in PerfDataGetProcessorUsage before converting to ULONG.
Fair enough. I wasn't sure we want to incur that overhead, but it also shouldn't be that much. Updated patch below.
Gerald
ChangeLog: Move out-of-domain checking into PerfDataGetProcessorUsage() and PerfDataGetProcessorSystemUsage().
Index: programs/taskmgr/perfdata.c =================================================================== RCS file: /home/wine/wine/programs/taskmgr/perfdata.c,v retrieving revision 1.6 diff -u -3 -p -r1.6 perfdata.c --- programs/taskmgr/perfdata.c 22 Oct 2007 14:57:58 -0000 1.6 +++ programs/taskmgr/perfdata.c 15 Nov 2007 13:01:27 -0000 @@ -332,11 +332,19 @@ ULONG PerfDataGetProcessCount(void)
ULONG PerfDataGetProcessorUsage(void) { + if( dbIdleTime < 0.0 ) + return 0; + if( dbIdleTime > 100.0 ) + return 100; return (ULONG)dbIdleTime; }
ULONG PerfDataGetProcessorSystemUsage(void) { + if( dbKernelTime < 0.0 ) + return 0; + if( dbKernelTime > 100.0 ) + return 100; return (ULONG)dbKernelTime; }
Index: programs/taskmgr/perfpage.c =================================================================== RCS file: /home/wine/wine/programs/taskmgr/perfpage.c,v retrieving revision 1.8 diff -u -3 -p -r1.8 perfpage.c --- programs/taskmgr/perfpage.c 23 May 2006 12:49:22 -0000 1.8 +++ programs/taskmgr/perfpage.c 15 Nov 2007 13:01:27 -0000 @@ -234,10 +234,6 @@ static DWORD WINAPI PerformancePageRefre */ CpuUsage = PerfDataGetProcessorUsage(); CpuKernelUsage = PerfDataGetProcessorSystemUsage(); - if (CpuUsage < 0 ) CpuUsage = 0; - if (CpuUsage > 100) CpuUsage = 100; - if (CpuKernelUsage < 0) CpuKernelUsage = 0; - if (CpuKernelUsage > 100) CpuKernelUsage = 100;
/* * Get the memory usage