Bug in systemload-plugin

Martti Kuparinen martti.kuparinen at iki.fi
Tue Nov 11 08:42:06 CET 2003


Hi!

I found a bug on xfce4-systemload-plugin which is visible on 64-bit
BSD platforms. According to the sysctl(3) manual page the sizes
are size_t (not int).

     int
     sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
             size_t newlen);

I have tested the following patch on NetBSD/sparc64 and it seems to work fine.

--- cpu.c.orig	2003-11-11 09:21:24.000000000 +0200
+++ cpu.c	2003-11-11 09:22:00.000000000 +0200
@@ -157,7 +157,7 @@
     gulong used, total;
     static int mib[] = { CTL_KERN, KERN_CP_TIME };
     u_int64_t cp_time[CPUSTATES];
-    int len = sizeof(cp_time);
+    size_t len = sizeof(cp_time);

     if (sysctl(mib, 2, &cp_time, &len, NULL, 0) < 0) {
             g_warning("Cannot get kern.cp_time");

I think the FreeBSD code has the same problem.

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

Martti



More information about the Xfce4-dev mailing list