[Pkg-wmaker-commits] [wmbubble] 40/207: fix whitespace in sys_linux.c

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 04:17:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbubble.

commit 43abb73ec09d520e69cab6a8dec58c280b470b60
Author: Robert Jacobs <rnjacobs at mit.edu>
Date:   Fri Jul 29 14:39:12 2011 -0700

    fix whitespace in sys_linux.c
---
 sys_linux.c | 138 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 66 insertions(+), 72 deletions(-)

diff --git a/sys_linux.c b/sys_linux.c
index 969c143..c898ab6 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -26,93 +26,87 @@
 extern BubbleMonData bm;
 
 /* returns current CPU load in percent, 0 to 100 */
-int system_cpu(void)
-{
-    unsigned int cpuload;
-    u_int64_t load, total, oload, ototal;
-    u_int64_t ab, ac, ad, ae;
-    int i;
-    FILE *stat;
-
-    stat = fopen("/proc/stat", "r");
-    fscanf(stat, "%*s %Ld %Ld %Ld %Ld", &ab, &ac, &ad, &ae);
-    fclose(stat);
-
-    /* Find out the CPU load */
-    /* user + sys = load
-     * total = total */
-    load = ab + ac + ad;	/* cpu.user + cpu.sys; */
-    total = ab + ac + ad + ae;	/* cpu.total; */
-
-    /* "i" is an index into a load history */
-    i = bm.loadIndex;
-    oload = bm.load[i];
-    ototal = bm.total[i];
-
-    bm.load[i] = load;
-    bm.total[i] = total;
-    bm.loadIndex = (i + 1) % bm.samples;
-
-    /*
-       Because the load returned from libgtop is a value accumulated
-       over time, and not the current load, the current load percentage
-       is calculated as the extra amount of work that has been performed
-       since the last sample. yah, right, what the fuck does that mean?
-     */
-    if (ototal == 0)		/* ototal == 0 means that this is the first time
-				   we get here */
-	cpuload = 0;
-    else if ((total - ototal) <= 0)
-	cpuload = 100;
-    else
-	cpuload = (100 * (load - oload)) / (total - ototal);
-
-    return cpuload;
+int system_cpu(void) {
+	unsigned int cpuload;
+	u_int64_t load, total, oload, ototal;
+	u_int64_t ab, ac, ad, ae;
+	int i;
+	FILE *stat;
+
+	stat = fopen("/proc/stat", "r");
+	fscanf(stat, "%*s %Ld %Ld %Ld %Ld", &ab, &ac, &ad, &ae);
+	fclose(stat);
+
+	/* Find out the CPU load */
+	/* user + sys = load
+	 * total = total */
+	load = ab + ac + ad;	/* cpu.user + cpu.sys; */
+	total = ab + ac + ad + ae;	/* cpu.total; */
+
+	/* "i" is an index into a load history */
+	i = bm.loadIndex;
+	oload = bm.load[i];
+	ototal = bm.total[i];
+
+	bm.load[i] = load;
+	bm.total[i] = total;
+	bm.loadIndex = (i + 1) % bm.samples;
+
+	/*
+	  Because the load returned from libgtop is a value accumulated
+	  over time, and not the current load, the current load percentage
+	  is calculated as the extra amount of work that has been performed
+	  since the last sample. yah, right, what the fuck does that mean?
+	*/
+	if (ototal == 0)		/* ototal == 0 means that this is the first time we get here */
+		cpuload = 0;
+	else if ((total - ototal) <= 0)
+		cpuload = 100;
+	else
+		cpuload = (100 * (load - oload)) / (total - ototal);
+
+	return cpuload;
 }
 
-void system_memory(void)
-{
-    char *p;
+void system_memory(void) {
+	char *p;
+	FILE *mem;
 
-    FILE *mem;
+	/* put this in permanent storage instead of stack */
+	static char shit[2048];
 
-    /* put this in permanent storage instead of stack */
-    static char shit[2048];
-
-    /* we might as well get both swap and memory at the same time.
-     * sure beats opening the same file twice */
-	    mem = fopen("/proc/meminfo", "r");
-	    memset(shit, 0, sizeof(shit));
-	    fread(shit, 2048, 1, mem);
-	    p = strstr(shit, "MemTotal");
-	    if (p) {
+	/* we might as well get both swap and memory at the same time.
+	 * sure beats opening the same file twice */
+	mem = fopen("/proc/meminfo", "r");
+	memset(shit, 0, sizeof(shit));
+	fread(shit, 2048, 1, mem);
+	p = strstr(shit, "MemTotal");
+	if (p) {
 		sscanf(p, "MemTotal:%Ld", &bm.mem_max);
 		bm.mem_max <<= 10;
 
 		p = strstr(p, "Active");
 		if (p) {
-		    sscanf(p, "Active:%Ld", &bm.mem_used);
-		    bm.mem_used <<= 10;
-
-		    p = strstr(p, "SwapTotal");
-		    if (p) {
-			sscanf(p, "SwapTotal:%Ld", &bm.swap_max);
-			bm.swap_max <<= 10;
+			sscanf(p, "Active:%Ld", &bm.mem_used);
+			bm.mem_used <<= 10;
 
-			p = strstr(p, "SwapFree");
+			p = strstr(p, "SwapTotal");
 			if (p) {
-			    sscanf(p, "SwapFree:%Ld", &bm.swap_used);
-			    bm.swap_used = bm.swap_max - (bm.swap_used << 10);
-
+				sscanf(p, "SwapTotal:%Ld", &bm.swap_max);
+				bm.swap_max <<= 10;
+
+				p = strstr(p, "SwapFree");
+				if (p) {
+					sscanf(p, "SwapFree:%Ld", &bm.swap_used);
+					bm.swap_used = bm.swap_max - (bm.swap_used << 10);
+				}
 			}
-		    }
 		}
-	    }
-	    fclose(mem);
+	}
+	fclose(mem);
 }
 
-void system_loadavg(void)
-{
+void system_loadavg(void) {
 	FILE *avg;
 	avg = fopen("/proc/loadavg", "r");
 	fscanf(avg, "%d.%d %d.%d %d.%d", &bm.loadavg[0].i, &bm.loadavg[0].f,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbubble.git



More information about the Pkg-wmaker-commits mailing list