[Pkg-wmaker-commits] [wmmon] 07/38: wmmon: Merged patch suggested by Bernard Cafarelli at Gentoo to prevent clobbering environment.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Aug 12 22:43:06 UTC 2017


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

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

commit 281cafbcaf9c9c4419de31acabcfcaafe8f2c232
Author: B. Kelly (wbk) <coydog at devio.us>
Date:   Sun Apr 1 18:58:33 2012 -0500

    wmmon: Merged patch suggested by Bernard Cafarelli at Gentoo to prevent clobbering environment.
    
      TODO: Still need to fix dependencies.
    
    wmmon.c:
      Updated version string to 1.2b2 (forgot this for 1.2b1).
    
      Fixed compiler warnings: added error checking for filesystem calls
      and commented out some preprocessor/C code that was apparently used
      to hardcode test cases.
    
      TODO: remove completely  soon if no ill effect.
---
 wmmon/Makefile |  6 +++---
 wmmon/wmmon.c  | 39 ++++++++++++++++++++++++++++++---------
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/wmmon/Makefile b/wmmon/Makefile
index da15b82..c49b0d3 100755
--- a/wmmon/Makefile
+++ b/wmmon/Makefile
@@ -6,14 +6,14 @@ OBJS =  wmmon.o \
 		../wmgeneral/list.o
 
 CFLAGS = -O2
-CC = cc $(CFLAGS)
+CC = cc
 
 
 .c.o:
-	$(CC) -c -Wall $< -o $*.o
+	$(CC) $(CFLAGS) -c -Wall $< -o $*.o
 
 wmmon: $(OBJS)
-	$(CC) -o wmmon $^ $(LIBDIR) $(LIBS)
+	$(CC) $(LDFLAGS) -o wmmon $^ $(LIBDIR) $(LIBS)
 
 debug: CFLAGS = -g3 
 debug: wmmon
diff --git a/wmmon/wmmon.c b/wmmon/wmmon.c
index 63fd768..254437e 100644
--- a/wmmon/wmmon.c
+++ b/wmmon/wmmon.c
@@ -116,11 +116,17 @@
  /* Defines */
 /***********/
 
-#define LEFT_ACTION (NULL)
+/* wbk - see notes below (search on these preprocessor variables).
+ * TODO: remove if causing no problems. This was probably used to 
+ * hardcode test cases.
+ */
+/*#define LEFT_ACTION (NULL)
 #define RIGHT_ACTION (NULL)
-#define MIDDLE_ACTION (NULL)
+#define MIDDLE_ACTION (NULL)*/
+
+#define WMMON_VERSION "1.2.b2"
 
-#define WMMON_VERSION "1.0.b2"
+#define HISTORY_ENTRIES 55
 
 #define HISTORY_ENTRIES 55
 
@@ -280,7 +286,8 @@ void wmmon_routine(int argc, char **argv) {
 	fp_diskstats = fopen("/proc/diskstats", "r");
 
 	if (fp) {
-		fscanf(fp, "%ld", &online_time);
+		if (fscanf(fp, "%ld", &online_time) == EOF)
+			perror("Error! fscanf() of /proc/uptime failed!\n");
 		ref_time = time(0);
 		fclose(fp);
 	}
@@ -292,9 +299,20 @@ void wmmon_routine(int argc, char **argv) {
 		stat_device[i].hisaddcnt = 0;
 	}
 
-	if (LEFT_ACTION) left_action = strdup(LEFT_ACTION);
-	if (RIGHT_ACTION) right_action = strdup(RIGHT_ACTION);
-	if (MIDDLE_ACTION) middle_action = strdup(MIDDLE_ACTION);
+	/* wbk - I don't fully understand this. Probably just a means of providing
+	 * test cases. ifdef'ing to clear compiler warnings. TODO: remove.		*/
+#ifdef LEFT_ACTION
+	if (LEFT_ACTION) 
+	  left_action = strdup(LEFT_ACTION);
+#endif
+#ifdef RIGHT_ACTION
+	if (RIGHT_ACTION) 
+		right_action = strdup(RIGHT_ACTION);
+#endif
+#ifdef MIDDLE_ACTION
+	if (MIDDLE_ACTION)
+		middle_action = strdup(MIDDLE_ACTION);
+#endif
 
 	/* Scan through the .rc files */
 	if (asprintf(&conffile, "/etc/wmmonrc") >= 0) {
@@ -661,7 +679,9 @@ void update_stat_mem(stat_dev *st, stat_dev *st2) {
 	unsigned long swapfree;
 	unsigned long free, shared, buffers, cached;
 
-	freopen("/proc/meminfo", "r", fp_meminfo);
+	if (freopen("/proc/meminfo", "r", fp_meminfo) == NULL)
+		perror("freopen() of /proc/meminfo failed!)\n");
+
 	while ((getline(&line, &line_size, fp_meminfo)) > 0) {
 		/* The original format for the first two lines of /proc/meminfo was
 		 * Mem: total used free shared buffers cached
@@ -777,7 +797,8 @@ void get_statistics(char *devname, long *is, long *ds, long *idle, long *ds2, lo
 		if ((fp_loadavg = freopen("/proc/loadavg", "r", fp_loadavg)) == NULL)
 			perror("ger_statistics(): freopen(proc/loadavg) failed!\n");
 
-		fscanf(fp_loadavg, "%f", &f);
+		if (fscanf(fp_loadavg, "%f", &f) == EOF)
+			perror("fscanf() failed to read f\n");
 		*is = (long) (100 * f);
 	}
 

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



More information about the Pkg-wmaker-commits mailing list