[Pkg-wmaker-commits] [wmsysmon] 10/13: *: more minor formatting cleanups

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Nov 22 19:52:03 UTC 2016


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

dtorrance-guest pushed a commit to branch upstream
in repository wmsysmon.

commit 6c62f57c3e8e80eb66a466c4e99817b8d6faa8ed
Author: Vito Caputo <vcaputo at gnugeneration.com>
Date:   Sat Aug 8 01:33:46 2015 -0700

    *: more minor formatting cleanups
---
 src/wmgeneral.c |  12 ++---
 src/wmsysmon.c  | 140 +++++++++++++++++++++++++++-----------------------------
 2 files changed, 74 insertions(+), 78 deletions(-)

diff --git a/src/wmgeneral.c b/src/wmgeneral.c
index dd3631d..c902e72 100644
--- a/src/wmgeneral.c
+++ b/src/wmgeneral.c
@@ -70,7 +70,7 @@ static Pixel GetColor(char *name) {
 
 
 void RedrawWindow(void) {
-	if(wmgen.dirty_w && wmgen.dirty_h)
+	if (wmgen.dirty_w && wmgen.dirty_h)
 	XCopyArea(display,
 		  wmgen.pixmap,
 		  iconwin,
@@ -82,7 +82,7 @@ void RedrawWindow(void) {
 		  wmgen.dirty_x,
 		  wmgen.dirty_y);
 
-	if(wmgen.dirty_w && wmgen.dirty_h)
+	if (wmgen.dirty_w && wmgen.dirty_h)
 	XCopyArea(display,
 		  wmgen.pixmap,
 		  win,
@@ -133,16 +133,16 @@ void DirtyWindow(int x, int y, unsigned int w, unsigned int h) {
 		h);
 #endif
 
-        if(x < wmgen.dirty_x) nx = x;
+        if (x < wmgen.dirty_x) nx = x;
         else nx = wmgen.dirty_x;
 
-        if(y < wmgen.dirty_y) ny = y;
+        if (y < wmgen.dirty_y) ny = y;
         else ny = wmgen.dirty_y;
 
-        if((x + w) > (wmgen.dirty_x + wmgen.dirty_w)) nw = (x + w) - nx;
+        if ((x + w) > (wmgen.dirty_x + wmgen.dirty_w)) nw = (x + w) - nx;
         else nw = (wmgen.dirty_x + wmgen.dirty_w) - nx;
 
-        if((y + h) > (wmgen.dirty_y + wmgen.dirty_h)) nh = (y + h) - ny;
+        if ((y + h) > (wmgen.dirty_y + wmgen.dirty_h)) nh = (y + h) - ny;
         else nh = (wmgen.dirty_y + wmgen.dirty_h) - ny;
 
 	wmgen.dirty_x = nx;
diff --git a/src/wmsysmon.c b/src/wmsysmon.c
index e49f75f..a94a042 100644
--- a/src/wmsysmon.c
+++ b/src/wmsysmon.c
@@ -2,21 +2,21 @@
 	wmsysmon -- system monitoring dockapp
 
 	Copyright (C) 1998-1999 Dave Clark - clarkd at skynet.ca
-        Copyright (C) 2000 Vito Caputo - swivel at gnugeneration.com
+	Copyright (C) 2000 Vito Caputo - swivel at gnugeneration.com
 
-        wmsysmon is free software; you can redistribute it and/or modify
-        it under the terms of the GNU General Public License as published by
-        the Free Software Foundation; either version 2 of the License, or
-        (at your option) any later version.
+	wmsysmon is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
 
-        wmsysmon is distributed in the hope that it will be useful,
-        but WITHOUT ANY WARRANTY; without even the implied warranty of
-        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-        GNU General Public License for more details.
+	wmsysmon is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
 
-        You should have received a copy of the GNU General Public License
-        along with this program; if not, write to the Free Software
-        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+	You should have received a copy of the GNU General Public License
+	along with this program; if not, write to the Free Software
+	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 #include <stdlib.h>
@@ -38,7 +38,6 @@
 #include <X11/xpm.h>
 #include <X11/extensions/shape.h>
 
-
 #include "wmgeneral.h"
 
 #ifdef HI_INTS
@@ -83,13 +82,13 @@ int	wmsysmon_mask_height = 64;
 long	start_time = 0;
 long	start_uptime = 0;
 int	counter = 0;
-int	Mem_l; /* line in /proc/meminfo "Mem:" is on */
-int	Swap_l; /* line in /proc/meminfo "Swap:" is on */
+int	Mem_l;	/* line in /proc/meminfo "Mem:" is on */
+int	Swap_l;	/* line in /proc/meminfo "Swap:" is on */
 int	intr_l;	/* line in /proc/stat "intr" is on */
-int	rio_l; /* line in /proc/stat "disk_rio" is on */
-int	wio_l; /* line in /proc/stat "disk_wio" is on */
-int	page_l; /* line in /proc/stat "page" is on */
-int	swap_l; /* line in /proc/stat "swap" is on */
+int	rio_l;	/* line in /proc/stat "disk_rio" is on */
+int	wio_l;	/* line in /proc/stat "disk_wio" is on */
+int	page_l;	/* line in /proc/stat "page" is on */
+int	swap_l;	/* line in /proc/stat "swap" is on */
 
 long	io_max;
 long	io_max_diff;
@@ -135,8 +134,8 @@ void wmsysmon_routine(int, char **);
 void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy);
 void DrawLite(int state, int dx, int dy);
 void DrawUptime(void);
-void DrawStuff( void );
-void DrawMem( void );
+void DrawStuff(void);
+void DrawMem(void);
 void DrawMeter(unsigned int, unsigned int, int, int);
 
 int main(int argc, char *argv[]) {
@@ -217,7 +216,7 @@ void wmsysmon_routine(int argc, char **argv)
 	createXBMfromXPM(wmsysmon_mask_bits, wmsysmon_master_xpm, wmsysmon_mask_width, wmsysmon_mask_height);
     
 	xfd = openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height);
-	if(xfd < 0) exit(1);
+	if (xfd < 0) exit(1);
 
 	pfd.fd = xfd;
 	pfd.events = (POLLIN);
@@ -244,21 +243,21 @@ void wmsysmon_routine(int argc, char **argv)
 	 * lines, for faster lookup throughout execution.
 	 */
 	/* /proc/meminfo */
-	for(i = 0; fgets(buf, 1024, memfp); i++) {
+	for (i = 0; fgets(buf, 1024, memfp); i++) {
 		if(strstr(buf, "Mem:")) Mem_l = i;
 		else if(strstr(buf, "Swap:")) Swap_l = i;
 	}
 
 	/* /proc/stat */
-	for(i = 0; fgets(buf, 1024, statfp); i++) {
-		if(strstr(buf, "disk_wio")) wio_l = i;
-		else if(strstr(buf, "disk_rio")) rio_l = i;
-		else if(strstr(buf, "page")) page_l = i;
-		else if(strstr(buf, "swap")) swap_l = i;
-		else if(strstr(buf, "intr")) intr_l = i;
+	for (i = 0; fgets(buf, 1024, statfp); i++) {
+		if (strstr(buf, "disk_wio")) wio_l = i;
+		else if (strstr(buf, "disk_rio")) rio_l = i;
+		else if (strstr(buf, "page")) page_l = i;
+		else if (strstr(buf, "swap")) swap_l = i;
+		else if (strstr(buf, "intr")) intr_l = i;
 	}
 
-	while(1) {
+	while (1) {
 		curtime = time(0);
 
 		DrawUptime();
@@ -286,11 +285,9 @@ void wmsysmon_routine(int argc, char **argv)
 			default:
 				printf("got: %i\n", Event.type);
 #endif
-        break;
+				break;
 			}
 		}
-
-/*		usleep(update_rate); */
 	}
 }
 
@@ -304,7 +301,7 @@ void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
 	 * since we're using only 4 lines for our level, the timer interrupt
 	 * usually kills the peak for the others so they never move. */
 
-	if(peak) {
+	if (peak) {
 		a = level * 3 / peak;
 	} else a = 0;
 
@@ -313,7 +310,7 @@ void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
 	fflush(stdout);
 #endif
 
-	if(a > 3) a = 3;
+	if (a > 3) a = 3;
 
 	copyXPMArea(meter[a][0],
 		    meter[a][1],
@@ -340,7 +337,7 @@ void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy)
 
 void DrawLite(int state, int dx, int dy)
 {
-	switch(state) {
+	switch (state) {
 		case B_RED:
 			copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
 			break;
@@ -368,7 +365,7 @@ void DrawUptime(void)
 	uptime /=60;
 	i = uptime % 60;
 
-	if(old_minutes != i || first) {
+	if (old_minutes != i || first) {
 		old_minutes = i;
 		sprintf(buf, "%02i", i);
 #ifdef HI_INTS
@@ -382,7 +379,7 @@ void DrawUptime(void)
 	uptime /=60;
 	i = uptime % 24;
 
-	if(old_hours != i || first) {
+	if (old_hours != i || first) {
 		old_hours = i;
 		sprintf(buf, "%02i", i);
 #ifdef HI_INTS
@@ -395,7 +392,7 @@ void DrawUptime(void)
 	/* blit days */
 	uptime /= 24;
 	i = uptime;
-	if(old_days != i || first) {
+	if (old_days != i || first) {
 		old_days = i;
 		sprintf(buf, "%03i", i);
 #ifdef HI_INTS
@@ -439,9 +436,8 @@ void DrawStuff( void )
 
 	statfp = freopen("/proc/stat", "r", statfp);
 
-
-	for(i = 0, ents = 0; ents < 5 && fgets(buf, 1024, statfp); i++) {
-		if(i == rio_l) {
+	for (i = 0, ents = 0; ents < 5 && fgets(buf, 1024, statfp); i++) {
+		if (i == rio_l) {
 			tok = strtok(buf, seps);
 
 			io += atoi(tok);
@@ -456,7 +452,7 @@ void DrawStuff( void )
 			io += atoi(tok);
 			tok = strtok(NULL, seps);
 			ents++;
-		} else if(i == wio_l) {
+		} else if (i == wio_l) {
 			tok = strtok(buf, seps);
 
 			io += atoi(tok);
@@ -471,14 +467,14 @@ void DrawStuff( void )
 			io += atoi(tok);
 			tok = strtok(NULL, seps);
 			ents++;
-		} else if(i == page_l) {
+		} else if (i == page_l) {
 			sscanf(buf, "%*s %ld %ld", &pageins, &pageouts);
 			ents++;
-		} else if(i == swap_l) {
+		} else if (i == swap_l) {
 			sscanf(buf, "%*s %ld %ld",
 				&swapins, &swapouts);
 			ents++;
-		} else if(i == intr_l) {
+		} else if (i == intr_l) {
 			sscanf(	buf,
 #ifdef HI_INTS
 				"%*s %*d %ld %ld %ld %ld %ld"
@@ -510,22 +506,22 @@ void DrawStuff( void )
 
 
 	/* ------------------ IO bar ------------------ */
-	if(io_max == 0) io_max = io;
+	if (io_max == 0) io_max = io;
     
-	if(io > io_max) iodiff = abs(io_max - io);
+	if (io > io_max) iodiff = abs(io_max - io);
 	else iodiff = 0;
 
 	io_max = io;
 
     
-	if(io_max_diff !=0) iopercent = ((float) iodiff / (float) io_max_diff) * 100.0;
+	if (io_max_diff !=0) iopercent = ((float) iodiff / (float) io_max_diff) * 100.0;
 	else iopercent = 0;
 
-	if(iodiff > io_max_diff) io_max_diff = iodiff;
+	if (iodiff > io_max_diff) io_max_diff = iodiff;
 
 	if (iopercent > 100) iopercent = 100;
 
-	if(iopercent != io_last || first) {
+	if (iopercent != io_last || first) {
 		io_last = iopercent;
 #ifdef HI_INTS
 		DrawBar(67, 36, 58, 4, iopercent, 3, 20);
@@ -534,17 +530,17 @@ void DrawStuff( void )
 #endif
 	}
 
-	if(int_mode == INT_LITES) {
+	if (int_mode == INT_LITES) {
 		/* top 8 ints */
 		for (i = 0; i < 8; i++) {
-			if ( ints[i] > last_ints[i] && !int_lites[i]) {
+			if (ints[i] > last_ints[i] && !int_lites[i]) {
 				int_lites[i] = 1;
 #ifdef HI_INTS
 				DrawLite(B_GREEN, 4 + (i * LITEW) + i, 43);
 #else
 				DrawLite(B_GREEN, 4 + (i * LITEW) + i, 51);
 #endif
-			} else if(ints[i] == last_ints[i] && int_lites[i]) {
+			} else if (ints[i] == last_ints[i] && int_lites[i]) {
 				int_lites[i] = 0;
 #ifdef HI_INTS
 				DrawLite(B_OFF, 4 + (i * LITEW) + i, 43);
@@ -555,14 +551,14 @@ void DrawStuff( void )
 		}
 		/* middle/bottom 8 */
 		for (i = 8; i < 16; i++) {
-			if ( ints[i] > last_ints[i] && !int_lites[i]) {
+			if (ints[i] > last_ints[i] && !int_lites[i]) {
 				int_lites[i] = 1;
 #ifdef HI_INTS
 				DrawLite(B_GREEN, 4 + ((i - 8) *LITEW) + (i - 8), 48);
 #else
 				DrawLite(B_GREEN, 4 + ((i - 8) *LITEW) + (i - 8), 56);
 #endif
-			} else if(ints[i] == last_ints[i] && int_lites[i]) {
+			} else if (ints[i] == last_ints[i] && int_lites[i]) {
 				int_lites[i] = 0;
 #ifdef HI_INTS
 				DrawLite(B_OFF, 4 + ((i - 8) * LITEW) + (i - 8), 48);
@@ -578,15 +574,15 @@ void DrawStuff( void )
 			if (ints[i] > last_ints[i] && !int_lites[i] ) {
 				int_lites[i] = 1;
 				DrawLite(B_GREEN, 4 + ((i - 16) * LITEW) + (i - 16), 53);
-			} else if(ints[i] == last_ints[i] && int_lites[i]) {
+			} else if (ints[i] == last_ints[i] && int_lites[i]) {
 				int_lites[i] = 0;
 				DrawLite(B_OFF, 4 + ((i -16) * LITEW) + (i - 16), 53);
 			}
 		}
 #endif
-	} else if(int_mode == INT_METERS) {
+	} else if (int_mode == INT_METERS) {
 		for (i = 0; i < 8; i++) {
-			if(last_ints[i]) {
+			if (last_ints[i]) {
 				intdiff = ints[i] - last_ints[i];
 				int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
 #ifdef HI_INTS
@@ -604,7 +600,7 @@ void DrawStuff( void )
 		}
 
 		for (i = 8; i < 16; i++) {
-			if(last_ints[i]) {
+			if (last_ints[i]) {
 				intdiff = ints[i] - last_ints[i];
 				int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
 #ifdef HI_INTS
@@ -623,7 +619,7 @@ void DrawStuff( void )
 
 #ifdef HI_INTS
 		for (i = 16; i < 24; i++) {
-			if(last_ints[i]) {
+			if (last_ints[i]) {
 				intdiff = ints[i] - last_ints[i];
 				int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
 
@@ -648,7 +644,7 @@ void DrawStuff( void )
 #else
 		DrawLite(B_RED, 51, 51);
 #endif
-	} else if(pagein_lite) {
+	} else if (pagein_lite) {
 		pagein_lite = 0;
 #ifdef HI_INTS
 		DrawLite(B_OFF, 51, 43);
@@ -664,7 +660,7 @@ void DrawStuff( void )
 #else
 		DrawLite(B_RED, 56, 51);
 #endif
-	} else if(pageout_lite) {
+	} else if (pageout_lite) {
 		pageout_lite = 0;
 #ifdef HI_INTS
 		DrawLite(B_OFF, 56, 43);
@@ -677,14 +673,14 @@ void DrawStuff( void )
 	last_pageouts = pageouts;
 
 	/* swap in/out */
-	if(swapins > last_swapins && !swapin_lite) {
+	if (swapins > last_swapins && !swapin_lite) {
 		swapin_lite = 1;
 #ifdef HI_INTS
 		DrawLite(B_RED, 51, 48);
 #else
 		DrawLite(B_RED, 51, 56);
 #endif
-	} else if(swapin_lite) {
+	} else if (swapin_lite) {
 		swapin_lite = 0;
 #ifdef HI_INTS
 		DrawLite(B_OFF, 51, 48);
@@ -700,7 +696,7 @@ void DrawStuff( void )
 #else
 		DrawLite(B_RED, 56, 56);
 #endif
-	} else if(swapout_lite) {
+	} else if (swapout_lite) {
 		swapout_lite = 0;
 #ifdef HI_INTS
 		DrawLite(B_OFF, 56, 48);
@@ -733,20 +729,20 @@ void DrawMem(void)
 
 	counter--;
 
-	if(counter >= 0) return; /* polling /proc/meminfo is EXPENSIVE */
+	if (counter >= 0) return; /* polling /proc/meminfo is EXPENSIVE */
 	counter = 3000000 / update_rate;
 
 	memfp = freopen("/proc/meminfo", "r", memfp);
 
-	for(i = 0, ents = 0; ents < 2 && fgets(buf, 1024, memfp); i++) {
-		if(i == Mem_l) {
+	for (i = 0, ents = 0; ents < 2 && fgets(buf, 1024, memfp); i++) {
+		if (i == Mem_l) {
 			sscanf(buf, "%*s %ld %ld %*d %*d %ld %ld",
 				&mem_total,
 				&mem_used,
 				&mem_buffers,
 				&mem_cache);
 			ents++;
-		} else if(i == Swap_l) {
+		} else if (i == Swap_l) {
 			sscanf(buf, "%*s %ld %ld %ld",
 				&swap_total,
 				&swap_used,
@@ -766,7 +762,7 @@ void DrawMem(void)
 		      /
 		      (float)swap_total) * 100;
 
-	if(mempercent != last_mem || first) {
+	if (mempercent != last_mem || first) {
 		last_mem = mempercent;
 #ifdef HI_INTS
 		DrawBar(67, 36, 58,4 , mempercent, 3, 4);
@@ -775,7 +771,7 @@ void DrawMem(void)
 #endif
 	}
 	    
-	if(swappercent != last_swap || first) {
+	if (swappercent != last_swap || first) {
 		last_swap = swappercent;
 #ifdef HI_INTS
 		DrawBar(67, 36, 58, 4, swappercent, 3, 12);

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



More information about the Pkg-wmaker-commits mailing list