ports/59080: [patch] x11/kdebase3: ksysguardd doesn't determine CPU stats correctly

Markus Brueffer brueffer at phoenix-systems.de
Sun Nov 9 13:30:15 UTC 2003


>Number:         59080
>Category:       ports
>Synopsis:       [patch] x11/kdebase3: ksysguardd doesn't determine CPU stats correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 09 05:30:12 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Markus Brueffer
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD cheops.phoenix 5.1-CURRENT FreeBSD 5.1-CURRENT #10: Tue Nov 4 20:05:23 CET 2003 brueffer at cheops.phoenix:/usr/obj/usr/src/sys/CHEOPS i386

>Description:
	For determining CPU stats, ksysguardd uses sysctlbyname.

        From sysctl(3):

        int
        sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp,
            size_t newlen);

        Unfortunately oldlenp is passed the wrong way which makes the call to
	sysctlbyname fail, resulting in all statistics about the CPU always to
        be 0.

	The attached patch corrects this. It was tested on several machines ranging
        from FreeBSD 4.9 up to the latest -CURRENT.

	Furthermore this patch should be committed to KDE-HEAD.

>How-To-Repeat:
	Open ksysguard and have a look at the CPU-pane. You won't see any CPU
	statistics there.

>Fix:

--- patch-ksysguard-ksysguardd-FreeBSD-CPU.c begins here ---
--- ksysguard/ksysguardd/FreeBSD/CPU.c.orig	Sat Nov  8 15:40:15 2003
+++ ksysguard/ksysguardd/FreeBSD/CPU.c	Sat Nov  8 15:16:40 2003
@@ -49,6 +49,8 @@
 long cp_diff[CPUSTATES];
 int cpu_states[CPUSTATES];
 
+size_t cp_time_len = sizeof(cp_time);
+
 void
 initCpuInfo(struct SensorModul* sm)
 {
@@ -73,7 +75,7 @@
 int
 updateCpuInfo(void)
 {
-        sysctlbyname("kern.cp_time", &cp_time, sizeof(cp_time), NULL, 0);
+        sysctlbyname("kern.cp_time", &cp_time, &cp_time_len, NULL, 0);
         percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff);
 	return (0);
 }
--- patch-ksysguard-ksysguardd-FreeBSD-CPU.c ends here ---



>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list