Cleaned whitespaces.

* cpu.c: (glibtop_get_cpu_s): Cleaned whitespaces.

	* open.c: (get_linux_version), (glibtop_open_s): Removed get_linux_version()
	Cleaned. Remove static struct utsname.
This commit is contained in:
Benoît Dejean
2004-05-26 16:52:32 +00:00
parent 0cdaaf1f62
commit 5af13a2a6a
3 changed files with 39 additions and 28 deletions

View File

@@ -1,3 +1,10 @@
2004-05-26 Benoît Dejean <tazforever@dlfp.org>
* cpu.c: (glibtop_get_cpu_s): Cleaned whitespaces.
* open.c: (get_linux_version), (glibtop_open_s): Removed get_linux_version()
Cleaned. Remove static struct utsname.
2004-05-26 Benoît Dejean <tazforever@dlfp.org>
* glibtop_server.h:
@@ -45,14 +52,14 @@
* procsignal.c: (glibtop_get_proc_signal_s):
* proctime.c: (glibtop_get_proc_time_s):
* procuid.c: (glibtop_get_proc_uid_s):
* swap.c: (glibtop_get_swap_s): Apply patch from Benoît Dejean
* swap.c: (glibtop_get_swap_s): Apply patch from Benoît Dejean
<bnet@ifrance.com> to fix overflow issues using strtol
(Closes: #129881)
2003-12-23 Bastien Nocera <hadess@hadess.net>
* mem.c: (glibtop_get_mem_s): Fix calculation of used memory,
patch by Benoît Dejea, <bnet@ifrance.com> (Closes: #129863)
patch by Benoît Dejean, <bnet@ifrance.com> (Closes: #129863)
2003-12-07 Jon K Hellan <hellan@acm.org>

View File

@@ -55,7 +55,7 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{
char buffer [BUFSIZ], *p;
int fd, len;
guint i;
int i;
glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
@@ -87,19 +87,19 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
/* 2.6 kernel */
buf->idle += strtoull(p, &p, 0); /* "iowait" */
buf->sys += strtoull(p, &p, 0); /* "irq" */
buf->sys += strtoull(p, &p, 0); /* "softirq" */
buf->sys += strtoull(p, &p, 0); /* "softirq" */
buf->total = buf->user + buf->nice + buf->sys + buf->idle;
buf->total = buf->user + buf->nice + buf->sys + buf->idle;
buf->frequency = 100;
buf->flags = _glibtop_sysdeps_cpu;
/*
/*
* PER CPU
*/
for (i = 0; i < GLIBTOP_NCPU && i < server->ncpu; i++) {
p = skip_line(p); /* move to ^ */
if (strncmp (p, "cpu", 3) || !isdigit (p [3]))

View File

@@ -31,22 +31,27 @@
*/
#include <sys/utsname.h>
static unsigned get_linux_version(void) {
static int linux_version_code = 0;
static unsigned linux_version_code = 0;
static void set_linux_version(void) {
static struct utsname uts;
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
if (linux_version_code) return;
if (uname(&uts) == -1) /* failure most likely implies impending death */
exit(1);
if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
fprintf(stderr, /* *very* unlikely to happen by accident */
"Non-standard uts for running kernel:\n"
"release %s=%d.%d.%d gives version code %d\n",
uts.release, x, y, z, LINUX_VERSION(x,y,z));
linux_version_code = LINUX_VERSION(x, y, z);
if(!linux_version_code) {
struct utsname uts;
unsigned x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
if (uname(&uts) == -1) /* failure most likely implies impending death */
exit(1);
if (sscanf(uts.release, "%u.%u.%u", &x, &y, &z) < 3)
fprintf(stderr, /* *very* unlikely to happen by accident */
"Non-standard uts for running kernel:\n"
"release %s=%u.%u.%u gives version code %d\n",
uts.release, x, y, z, LINUX_VERSION(x,y,z));
linux_version_code = LINUX_VERSION(x, y, z);
}
return linux_version_code;
}
/* ======================================================= */
@@ -65,8 +70,7 @@ glibtop_open_s (glibtop *server, const char *program_name,
server->name = program_name;
set_linux_version ();
server->os_version_code = (unsigned long) linux_version_code;
server->os_version_code = get_linux_version();
fd = open (FILENAME, O_RDONLY);
if (fd < 0)
@@ -79,16 +83,16 @@ glibtop_open_s (glibtop *server, const char *program_name,
close (fd);
buffer [len] = '\0';
for (server->ncpu = 0; server->ncpu < GLIBTOP_NCPU; server->ncpu++) {
p = skip_line(p);
if (strncmp (p, "cpu", 3) || !isdigit (p [3]))
break;
}
#if DEBUG
#if DEBUG
printf ("\nThis machine has %d CPUs.\n\n", server->ncpu);
#endif
}