-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Carlos,
When you get a chance, can you please apply this patch to the repository? This ought to get rid of those annoying compiler warnings with wmmon. To anyone else who is testing the latest wmmon, please try this patch and let me know if you still get any compiler warnings, or if there are any other issues you think should be addressed. If you are making the debug build, see the commit log regarding a known issue with the makefile and its workaround. I'm starting work on color swapping, and patching in the Gentoo "-b" flag, using this as an opportunity to try to learn branches in git, so I wanted to get this checked in, in case I lose anything. I am starting to get a handle on git, but it is still a bit intimidating. I should have more for you soon. Thanks! - -wbk - -- [email protected] http://devio.us/~coydog Public key: http://devio.us/~coydog/public_keys.txt -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAEBAgAGBQJPePBnAAoJEPAprai3G3cM7IoQAJ6WtDSVMIoW0RpxhxwbanOf f7WRDhtY1MpDbfI9T1F1ejXRQfWwGPxe4Xmre6SjLx34H1mx80X242aJDo23AyE1 lq8JQX57EU3ZUltQPj7UJRo8drYU2Hu/MU2fP/qmb5FPUqCEzrxNl0niTeuNHTUH xiGTieQl917H9x2wOgLeD/mApSrE+V7NC/iC2GlyDX8SGMQyRLkQlqsEwNMA/m39 gzM6uNyRLZA5ri0sv0Fp0xpepnGmOx/SYci2vrnSpBkuooWSCQM+FpiJCyZT4gQr FgTG3+4NVUwgURr/uslX9KBRV+dgDpF7ztr+QONoq63pKfM5VaHVjQVteYSuw2S/ Vgrth3BtcoCJ3zz2QF7Nki4TIoK3Rhll+l++Jwy1vlIuyvirAfyVRD1YP0L+hIbe BzCtYDSETEKZurUhHGc5e9jE4vn1TPJoyqE7yVaGXyj4ExQqH1iASr/1urxg1WVR 2eiEMPXdLY25D08dBo4DNcFqJAoHUuAj9B1th0yaxoH4XdnG6EXg6OlkhNfueHBU S2qSpsGZItapckbkPu27tG23nf8dmMVw6eRsAwhMO+vYhYFbGLd3ecvrIGQGSkss BhisgEOgIlMMSpgCzI6AYYtAbckp6rJL3K0Fp5LeSyXxSmnicsNFXcdKU6tOSHLB MmNEW7NcQ5TdH++WW3Ay =3exE -----END PGP SIGNATURE-----
From c1ca0ff735153962bddcf1087390fc2d8ef29a4d Mon Sep 17 00:00:00 2001 From: B. Kelly (wbk) <[email protected]> Date: Sun, 1 Apr 2012 18:58:33 -0500 Subject: [PATCH] Makefile: 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/wmmon/Makefile | 6 +++--- wmmon/wmmon/wmmon.c | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/wmmon/wmmon/Makefile b/wmmon/wmmon/Makefile index da15b82..c49b0d3 100755 --- a/wmmon/wmmon/Makefile +++ b/wmmon/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/wmmon.c b/wmmon/wmmon/wmmon.c index 63fd768..254437e 100644 --- a/wmmon/wmmon/wmmon.c +++ b/wmmon/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); } -- 1.7.3.4
